diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml deleted file mode 100644 index bec62ac..0000000 --- a/.github/workflows/pre-commit.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Run pre-commit hooks - -env: - DEFAULT_PYTHON: "3.10" - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - pre-commit: - name: Run pre-commit hooks - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - name: Setup Python ${{ env.DEFAULT_PYTHON }} - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 - with: - python-version: ${{ env.DEFAULT_PYTHON }} - - - name: Run pre-commit - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..e768070 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,56 @@ +name: Create release & publish to PyPI +# If ran manually, e.g. with ref set to "refs/tags/v1.2.3", set the run name to "Publish refs/tags/v1.2.3". +run-name: ${{ inputs.ref && format('Publish {0}', inputs.ref) || null }} + +on: + push: + branches: + - main + # Run daily to keep the release PR date current + schedule: + - cron: '1 0 * * *' + workflow_dispatch: + inputs: + ref: + description: "The branch, tag or SHA to publish." + required: true + type: string + +jobs: + release-please: + uses: City-of-Helsinki/.github/.github/workflows/release-please.yml@main + permissions: + contents: write + pull-requests: write + with: + include-component-in-tag: false + + build: + needs: + - release-please + uses: City-of-Helsinki/.github/.github/workflows/build-python-dists.yml@main + with: + ref: ${{ inputs.ref }} + # Run build job if a release was created or a ref was specified (i.e. workflow was invoked manually) + if: ${{ needs.release-please.outputs.release_created || inputs.ref }} + + publish-to-pypi: + name: Publish to PyPI + runs-on: ubuntu-latest + needs: + - build + # Run publish job if an artifact was uploaded + if: ${{ needs.build.outputs.artifact_name }} + environment: + name: pypi + url: https://pypi.org/p/django-ilmoitin + permissions: + id-token: write # mandatory for trusted publishing + steps: + - name: Download all the dists + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: ${{ needs.build.outputs.artifact_name }} + path: dist/ + - name: Publish distribution to PyPI + uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 0f6e43d..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Publish to PyPI - -on: - push: - tags: - - 'release-*' - -jobs: - build-and-publish: - name: Build and publish - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: 3.10 - - name: Install dependencies - run: pip install -U setuptools wheel build - - name: Build - run: python -m build . - - name: Publish - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }} - verbose: true