Обновил workflow для создания релиза #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check and Create Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
check_and_release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
- name: Get current version | |
id: get_version | |
run: | | |
echo "VERSION=$(poetry version -s)" >> $GITHUB_ENV | |
- name: Get latest release version | |
id: get_latest_release | |
run: | | |
LATEST_RELEASE=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name) | |
echo "LATEST_RELEASE=${LATEST_RELEASE}" >> $GITHUB_ENV | |
- name: Compare versions | |
id: compare_versions | |
run: | | |
if [ "${{ env.VERSION }}" != "${{ env.LATEST_RELEASE }}" ]; then | |
echo "NEW_VERSION=true" >> $GITHUB_ENV | |
else | |
echo "NEW_VERSION=false" >> $GITHUB_ENV | |
fi | |
- name: Build package | |
if: env.NEW_VERSION == 'true' | |
run: | | |
poetry build | |
- name: Create new release | |
if: env.NEW_VERSION == 'true' | |
id: create_release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ env.VERSION }} | |
release_name: Release ${{ env.VERSION }} | |
body: | | |
New release ${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} | |
- name: Upload release asset | |
if: env.NEW_VERSION == 'true' | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/your-package-name-${{ env.VERSION }}.tar.gz | |
asset_name: your-package-name-${{ env.VERSION }}.tar.gz | |
asset_content_type: application/gzip | |
env: | |
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} |