-
Notifications
You must be signed in to change notification settings - Fork 1
77 lines (74 loc) · 2.3 KB
/
tag-n-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
permissions:
contents: write
outputs:
tag: v${{ steps.bump.outputs.version }}
changelog: ${{ steps.changelog.outputs.body }}
is_new_version: ${{ steps.is-new-version.outputs.is_new_version }}
steps:
- id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_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: .body.md
git_redirect_stderr: true
commit: true
push: false
no_raise: 21
- id: is-new-version
shell: bash
run: |
if [ "${PREVIOUS_REVISION}" != "${REVISION}" ]; then
echo "is_new_version=1" >>"$GITHUB_OUTPUT"
fi
# pushing seperately to use correct auth set up during actions/checkout
- run: git push origin main:main --tags
- id: changelog
run: |
{
echo 'body<<EOF'
cat .body.md
echo EOF
} >> "$GITHUB_OUTPUT"
cat .body.md >> $GITHUB_STEP_SUMMARY
relase:
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:
BODY: ${{ needs.tag.outputs.changelog }}
TAG: ${{ needs.tag.outputs.tag }}
with:
script: |
const { BODY, TAG } = process.env
github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: TAG,
body: BODY,
})