From fcc99bd2cedc08ac256abe41003816910c6797ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 21 Nov 2023 17:50:23 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Publish=20release=20artifacts=20?= =?UTF-8?q?as=20release=20assets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #4908 --- .github/workflows/build.yml | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 66bbab9fa..3ffd8fb99 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -195,8 +195,8 @@ jobs: name: octoprint-logs path: ${{ github.workspace }}/e2econfig/logs - publish-on-testpypi: - name: 📦 Publish on TestPyPI + publish-on-release: + name: 📦 Publish on GitHub release if: github.event_name == 'release' && github.repository == 'OctoPrint/OctoPrint' needs: - pre-commit @@ -211,12 +211,39 @@ jobs: with: name: dist path: dist - - name: 📦 Publish to index + + - name: ⬆ Upload to release + run: | + UPLOAD_URL="https://uploads.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets" + for file in dist/*; do + [ -e "$file" ] || exit 1 + echo "Uploading $file..." + response=$(curl -s -XPOST \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Content-Type: $(file -b --mime-type $file)" \ + --data-binary @$file \ + "$UPLOAD_URL?name=$(basename $file)") + echo "$response" | jq -e '.errors' >/dev/null && echo "Error uploading $file to release: $response" && exit 1 || true + done + + publish-on-testpypi: + name: 📦 Publish on TestPyPI + if: github.event_name == 'release' && github.repository == 'OctoPrint/OctoPrint' + needs: + - publish-on-release + runs-on: ubuntu-latest + steps: + - name: ⬇ Download build result + uses: actions/download-artifact@v3 + with: + name: dist + path: dist + - name: ⬆ Upload to index uses: pypa/gh-action-pypi-publish@release/v1 continue-on-error: true with: password: ${{ secrets.testpypi_password }} - repository_url: https://test.pypi.org/legacy/ + repository-url: https://test.pypi.org/legacy/ publish-on-pypi: name: 📦 Publish tagged releases to PyPI @@ -229,7 +256,7 @@ jobs: with: name: dist path: dist - - name: 📦 Publish to index + - name: ⬆ Publish to index uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.pypi_password }}