-
Notifications
You must be signed in to change notification settings - Fork 30
106 lines (88 loc) · 3.68 KB
/
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Release
on:
pull_request_target:
branches:
- main
types: [ closed ]
jobs:
changelog:
uses: "OpenTermsArchive/engine/.github/workflows/changelog.yml@main"
test:
uses: "OpenTermsArchive/engine/.github/workflows/test.yml@main"
release:
if: github.event.pull_request.merged == true && needs.changelog.outputs.no_functional_changes != 'true'
needs: [ changelog, test ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
- name: Install dependencies
run: npm ci
- name: Configure Git author
run: |
git config --global user.name "Open Terms Archive Release Bot"
git config --global user.email "release-bot@opentermsarchive.org"
- name: Bump package version
run: |
echo "Release type found: '$(npm run changelog --silent -- --get-release-type)'"
echo "NEW_VERSION=$(npm --no-git-tag-version version $(npm run changelog --silent -- --get-release-type))" >> $GITHUB_ENV
- name: Update changelog unreleased section with new version
run: npm run changelog --silent -- --release ${{ github.event.number }} # github.event.number refers to the pull request number
- name: Commit CHANGELOG.md and package.json changes and create tag
run: |
git add "package.json"
git add "package-lock.json"
git add "CHANGELOG.md"
git commit -m "Release ${{ env.NEW_VERSION }}"
git tag ${{ env.NEW_VERSION }}
- name: Run status checks for release commit on temporary branch # Use temporary branch to enable pushing commits to this branch protected by required status checks
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
branch: main
unprotect_reviews: true
- name: Push changes to repository
run: git push origin && git push --tags
- name: Read version changelog
run: |
echo "VERSION_CHANGELOG<<EOF" >> $GITHUB_ENV
echo "$(npm run changelog --silent -- --get-version-content ${{ env.NEW_VERSION }})" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.NEW_VERSION }}
body: ${{ env.VERSION_CHANGELOG }}
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
- name: Publish to NPM public repository
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPMJS_ACCESS_TOKEN }}
- name: Trigger documentation deploy
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.TRIGGER_DOCS_DEPLOY_TOKEN }}
event-type: engine-release
repository: OpenTermsArchive/docs
client-payload: '{"version": "${{ env.NEW_VERSION }}"}'
clean_changelog:
if: github.event.pull_request.merged == true && needs.changelog.outputs.no_functional_changes == 'true'
needs: [ changelog ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
- name: Install dependencies
run: npm ci
- name: Configure Git author
run: |
git config --global user.name "Open Terms Archive Release Bot"
git config --global user.email "release-bot@opentermsarchive.org"
- name: Erase unreleased information from changelog
run: |
npm run changelog --silent -- --clean-unreleased
git commit -m "Clean changelog" CHANGELOG.md
git push origin