-
Notifications
You must be signed in to change notification settings - Fork 2
77 lines (73 loc) · 2.33 KB
/
tag-and-release.yml
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
68
69
70
71
72
73
74
75
76
77
name: tag and release new version
on:
pull_request_target:
types:
- closed
jobs:
tag:
name: create git tag
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == github.event.repository.default_branch
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.bump.outputs.version }}
changes: ${{ steps.details.outputs.changes }}
is_new_version: ${{ steps.details.outputs.is_new_version }}
steps:
- id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.PUBLIC_RELEASE_MANAGER_ID }}
private-key: ${{ secrets.PUBLIC_RELEASE_MANAGER_SECRET }}
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
ref: ${{ github.event.repository.default_branch }}
# `fetch-depth` > 0 is required to have `ref` have an effect
fetch-depth: 999
fetch-tags: true
- id: bump
uses: commitizen-tools/commitizen-action@master
with:
changelog_increment_filename: .changes.md
git_redirect_stderr: true
commit: true
push: false
no_raise: 21
- id: details
shell: bash
run: |
{
echo 'changes<<EOF'
cat .changes.md
echo EOF
} >> "$GITHUB_OUTPUT"
if [ "$REVISION" != "$PREVIOUS_REVISION" ]; then
echo "is_new_version=1" >> "$GITHUB_OUTPUT"
# pushing seperately to use correct auth set up during actions/checkout
git push --atomic --tags origin HEAD:${GITHUB_REF_NAME}
fi
release:
name: create new release
needs:
- tag
if: ${{ needs.tag.outputs.is_new_version }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/github-script@v7
env:
CHANGES: ${{ needs.tag.outputs.changes }}
TAG: ${{ needs.tag.outputs.tag }}
with:
script: |
const { CHANGES, TAG } = process.env
github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: TAG,
body: CHANGES,
})
- name: Build package
run: poetry build
- name: Publish package to PyPI