dmyersturnbull/pocketutils

View on GitHub
.github/workflows/deploy-packages.yaml

Summary

Maintainability
Test Coverage
# SPDX-FileCopyrightText: Copyright 2020-2023, Contributors to pocketutils
# SPDX-PackageHomePage: https://github.com/dmyersturnbull/pocketutils
# SPDX-License-Identifier: Apache-2.0

name: Deploy packages

on:
  push:
    tags: ["v*"]

concurrency:
  group: ${{ github.workflow }}-${{ github.sha }}
  cancel-in-progress: false

permissions:
  contents: write
  # This is used to complete the identity challenge
  # with sigstore/fulcio when running outside of PRs.
  id-token: write
  packages: write

jobs:
  publish-github-release:
    name: Publish GitHub Release
    needs: [bump]
    runs-on: ubuntu-latest
    steps:
      - name: Download artifacts
        uses: actions/download-artifact@v3
        with:
          name: dist
      - name: Get release notes
        id: release-notes
        run: echo "release_notes=$(cz changelog --dry-run ${{ github.ref_name }})" >> $GITHUB_OUTPUT
      - name: Publish GitHub release
        uses: softprops/action-gh-release@v1
        #if: ${{ github.ref_type == 'tag' }}
        with:
          draft: false
          generate_release_notes: false
          body: ${{ steps.release-notes.outputs.release_notes }}
          fail_on_unmatched_files: true
          token: ${{ github.token }}
          files: dist/*

  publish-pypi:
    name: Publish to PyPi
    needs: [bump]
    runs-on: ubuntu-latest
    steps:
      - name: Download artifacts
        uses: actions/download-artifact@v3
        with:
          name: dist
      - name: Install hatch
        run: pip install hatch~=1.9
      - name: Publish to PyPi
        run: hatch publish
        env:
          HATCH_INDEX_USER: __token__
          HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }}
        if: ${{ env.pypi_token != '' }}