-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (88 loc) · 3.37 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
name: Release
on:
workflow_dispatch
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.DISY_RELEASE_APP_ID }}
private-key: ${{ secrets.DISY_RELEASE_APP_SECRET }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: 'npm'
- run: npm ci
- run: npm test
- run: npm run build
# Needed for creating the tag
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Prepare package version (e.g. 1.2.3-dev => 1.2.3)
run: |
npm --no-git-tag-version version patch # Remove -dev suffix
echo "RELEASE_VERSION=$(npm pkg get version | tr -d \")" >> $GITHUB_ENV # Determine RELEASE_VERSION
- name: Set release tag to 'latest'
run: echo "RELEASE_TAG=latest" >> $GITHUB_ENV
# Update changelog unreleased section with new version
- name: Update changelog
uses: superfaceai/release-changelog-action@v2
with:
path-to-changelog: CHANGELOG.md
version: ${{ env.RELEASE_VERSION }}
operation: release
- name: Commit release and tag it
run: |
git add "package.json"
git add "package-lock.json"
git add "CHANGELOG.md"
git commit -m "chore: release ${{ env.RELEASE_VERSION }}"
git tag v${{ env.RELEASE_VERSION }}
- name: Push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: git push origin && git push --tags
- id: get-changelog
name: Get version changelog
uses: superfaceai/release-changelog-action@v2
with:
path-to-changelog: CHANGELOG.md
version: ${{ env.RELEASE_VERSION }}
operation: read
- name: Update GitHub release documentation
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.RELEASE_VERSION }}
body: ${{ steps.get-changelog.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish npm package
run: |
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
npm publish --verbose --access=public --tag=${{ env.RELEASE_TAG }}
env:
NPM_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }}
- name: Bump package version to new dev version (e.g. 1.2.3 => 1.2.4-dev)
run: |
npm --no-git-tag-version version patch # Determine next release version
DEV_VERSION=$(npm pkg get version | tr -d \")-dev && echo "DEV_VERSION=$DEV_VERSION" >> $GITHUB_ENV # Determine DEV_VERSION with -dev suffix
npm --no-git-tag-version version $DEV_VERSION # Set main to $DEV_VERSION
- name: Commit version bump
run: |
git add "package.json"
git add "package-lock.json"
git commit -m "chore: bump up version to ${{ env.DEV_VERSION }}"
- name: Push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: git push origin