diff --git a/.github/workflows/build-and-draft-release.yml b/.github/workflows/build-and-draft-release.yml deleted file mode 100644 index 7355c03..0000000 --- a/.github/workflows/build-and-draft-release.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: "Build and draft a release" - -on: - workflow_dispatch: - push: - tags: - - '*.*.*' - -permissions: - contents: write - discussions: write - -jobs: - build-and-draft-release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up Python environment - uses: actions/setup-python@v5 - with: - python-version: "3.x" - - - name: Build package - run: | - pip install build - python -m build - - - name: Draft a release - uses: softprops/action-gh-release@v2 - with: - discussion_category_name: New releases - draft: true - generate_release_notes: true - files: | - dist/* diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml new file mode 100644 index 0000000..3a9540d --- /dev/null +++ b/.github/workflows/build-and-publish.yml @@ -0,0 +1,103 @@ +name: Build, Release, Publish + +on: + workflow_dispatch: + push: + tags: + - "*.*.*" + +jobs: + build: + name: Build package + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python environment + uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: Build package + run: | + pip install build + python -m build + + - name: Store the distribution files + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + draft-release: + name: Draft a release + runs-on: ubuntu-latest + needs: + - build + permissions: + contents: write + discussions: write + + steps: + - name: Download the distribution files + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + - name: Draft a release + uses: softprops/action-gh-release@v2 + with: + discussion_category_name: New releases + draft: true + generate_release_notes: true + files: | + dist/* + + publish-to-pypi: + name: Publish distribution to PyPI + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + environment: + name: pypi + url: https://pypi.org/p/arcaea-offline-ocr + permissions: + id-token: write + + steps: + - name: Download the distribution files + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + - name: Publish distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + publish-to-testpypi: + name: Publish distribution to TestPyPI + runs-on: ubuntu-latest + needs: + - build + environment: + name: testpypi + url: https://test.pypi.org/p/arcaea-offline-ocr + permissions: + id-token: write + + steps: + - name: Download the distribution files + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + - name: Publish distribution to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/