From 1ddb60d2413fb48f7795859a3fcc5b5783bea523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9on=20van=20Velzen?= Date: Tue, 29 Oct 2024 21:35:20 +0100 Subject: [PATCH] Automatically create Github release in publish.yaml --- .github/workflows/publish.yaml | 45 +++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index efcc5ad..4d49306 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -7,6 +7,8 @@ jobs: publish_wheels: runs-on: ubuntu-latest steps: + - name: Checkout code + uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: @@ -17,12 +19,49 @@ jobs: with: workflow: build-and-test.yaml branch: main - name: .*-wheel + name: (.*-wheel)|source-distribution name_is_regexp: true search_artifacts: true - - name: List + - name: List artifacts run: | ls **/*.whl - + ls source-distribution/*.tar.gz + - name: Extract version information + run: | + VERSION=$(python3 ./setup.py --version) + TAG=v$VERSION + echo "Version found: $VERSION" + echo "Using tag: $TAG" + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "TAG=v$VERSION" >> $GITHUB_ENV + if [[ "$VERSION" == *rc* ]]; then + echo "PRERELEASE=true" >> $GITHUB_ENV + echo "This is a prerelease." + else + echo "PRERELEASE=false" >> $GITHUB_ENV + echo "This is a full release." + fi + - name: Create Git tag + run: | + git tag $TAG + git push origin $TAG + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.TAG }} + release_name: ${{ env.TAG }} + prerelease: ${{ env.PRERELEASE }} + draft: false + - name: Upload Release Assets + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./source-distribution/traceon-${{ env.VERSION }}.tar.gz # Adjust the path to your wheel