From 5474cc3009e695bd61a9e656ca20988f82bb2d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Sun, 13 Oct 2024 18:04:10 +0200 Subject: [PATCH] backport release workflow from main branch --- .github/workflows/release.yaml | 58 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 44 -------------------------- 2 files changed, 58 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/release.yaml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000000..001273edd3e --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,58 @@ +name: Release + +on: + release: + types: [published] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + + - run: pipx run build + + - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + with: + name: distfiles + path: dist/ + if-no-files-found: error + + upload-github: + name: Upload (GitHub) + runs-on: ubuntu-latest + permissions: + contents: write + needs: build + steps: + # We need to be in a git repo for gh to work. + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + name: distfiles + path: dist/ + + - run: gh release upload ${{ github.event.release.tag_name }} dist/*.{tar.gz,whl} + env: + GH_TOKEN: ${{ github.token }} + + upload-pypi: + name: Upload (PyPI) + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/poetry/ + permissions: + id-token: write + needs: build + steps: + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + name: distfiles + path: dist/ + + - uses: pypa/gh-action-pypi-publish@f7600683efdcb7656dec5b29656edb7bc586e597 # v1.10.3 + with: + print-hash: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 359cfb9f28d..00000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Release - -on: - push: - tags: - - '*.*.*' - -jobs: - release: - name: Release - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Poetry - run: pipx install poetry - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: "3.12" - cache: poetry - - - name: Build project for distribution - run: poetry build - - - name: Check Version - id: check-version - run: | - [[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo prerelease=true >> $GITHUB_OUTPUT - - - name: Create Release - uses: ncipollo/release-action@v1 - with: - artifacts: "dist/*" - token: ${{ secrets.GITHUB_TOKEN }} - draft: false - prerelease: steps.check-version.outputs.prerelease == 'true' - - - name: Publish to PyPI - env: - POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} - run: poetry publish