|
| 1 | +name: Publish package |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + get-release-tag: |
| 8 | + name: Get the package version |
| 9 | + runs-on: ubuntu-latest |
| 10 | + outputs: |
| 11 | + package-version: ${{ steps.package-version.outputs.package-version }} |
| 12 | + steps: |
| 13 | + - name: Check out π |
| 14 | + uses: actions/checkout@v4.1.1 |
| 15 | + - name: Set up Python π |
| 16 | + uses: actions/setup-python@v4.7.1 |
| 17 | + with: |
| 18 | + cache: pip |
| 19 | + - name: Get the package version π |
| 20 | + id: package-version |
| 21 | + run: |
| 22 | + echo "package-version=$(python ./scripts/package_version.py)" >> "$GITHUB_OUTPUT" |
| 23 | + pypi-publish: |
| 24 | + needs: get-release-tag |
| 25 | + name: Upload to PyPI |
| 26 | + runs-on: ubuntu-latest |
| 27 | + environment: |
| 28 | + name: PyPI |
| 29 | + url: https://pypi.org/p/python-gitmojis |
| 30 | + permissions: |
| 31 | + id-token: write |
| 32 | + steps: |
| 33 | + - name: Check out π |
| 34 | + uses: actions/checkout@v4.1.1 |
| 35 | + - name: Set up Python π |
| 36 | + uses: actions/setup-python@v4.7.1 |
| 37 | + with: |
| 38 | + cache: pip |
| 39 | + - name: Install PyPA `build` package π¦ |
| 40 | + run: | |
| 41 | + python -m pip install --upgrade pip |
| 42 | + python -m pip install build |
| 43 | + - name: Build the package π· |
| 44 | + run: |
| 45 | + python -m build |
| 46 | + - name: Publish to PyPI π |
| 47 | + uses: pypa/gh-action-pypi-publish@v1.8.10 |
| 48 | + create-release-tag: |
| 49 | + needs: |
| 50 | + - get-release-tag |
| 51 | + - pypi-publish |
| 52 | + name: Create the release tag |
| 53 | + runs-on: ubuntu-latest |
| 54 | + permissions: |
| 55 | + contents: write |
| 56 | + steps: |
| 57 | + - name: Check out π |
| 58 | + uses: actions/checkout@v4.1.1 |
| 59 | + - name: Create tag π |
| 60 | + run: | |
| 61 | + git config user.name "${{ github.actor }}" |
| 62 | + git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" |
| 63 | + git tag "${{ needs.get-release-tag.outputs.package-version }}" |
| 64 | + git push --tags |
| 65 | + publish-release: |
| 66 | + needs: |
| 67 | + - get-release-tag |
| 68 | + - create-release-tag |
| 69 | + name: Publish GitHub release |
| 70 | + runs-on: ubuntu-latest |
| 71 | + permissions: |
| 72 | + contents: write |
| 73 | + steps: |
| 74 | + - name: Check out π |
| 75 | + uses: actions/checkout@v4.1.1 |
| 76 | + - name: Publish GitHub Release π |
| 77 | + uses: softprops/action-gh-release@v0.1.15 |
| 78 | + with: |
| 79 | + tag_name: ${{ needs.get-release-tag.outputs.package-version }} |
| 80 | + generate_release_notes: true |
0 commit comments