-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (60 loc) · 2.02 KB
/
publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Publish the package to pypi
on: workflow_dispatch
jobs:
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/lazy-github
permissions:
id-token: write
outputs:
new-version: ${{ steps.calculate-version.outputs.version }}
steps:
# Perform a bunch of setup
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: yezz123/setup-uv@v4
- name: Calculate version
id: calculate-version
run: |
new_version=$(uvx hatch version)
echo "version=${new_version}" >> $GITHUB_OUTPUT
# Build the distribution
- name: Build lazy-github distribution
run: uvx hatch build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
create-tag-and-release:
name: Create tag
needs: pypi-publish
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: create-tag
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/v${{ needs.pypi-publish.outputs.new-version }}',
sha: context.sha
})
- name: Create release
run: |
gh release create "v${{ needs.pypi-publish.outputs.new-version }}" \
--title="LazyGithub ${tag#v}" \
--generate-notes
notify-discord:
name: Notify when this workflow completes (regardless of success or failure)
needs: pypi-publish
runs-on: ubuntu-latest
steps:
- uses: nobrayner/discord-webhook@v1
with:
title: "Version ${{ needs.pypi-publish.outputs.new-version }} published to PyPi"
description: "Check out the new version [here](https://pypi.org/project/lazy-github/${{ needs.pypi-publish.outputs.new-version }}/)"
github-token: ${{ secrets.github_token }}
discord-webhook: ${{ secrets.DISCORD_WEBHOOK }}