-
Notifications
You must be signed in to change notification settings - Fork 5
103 lines (84 loc) · 3.27 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
name: Release
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
jobs:
test-and-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'yarn'
- name: Install dependencies
run: yarn install
- name: Check linting
run: yarn lint
- name: Run tests
run: yarn test
- name: Build
run: yarn build
build_docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 21
cache: yarn
- name: Install and build documentation
run: |
cd documentation
yarn install --frozen-lockfile
yarn build
env:
DOCS_BASE_URL: ${{ vars.DOCS_BASE_URL }}
DOCS_URL: ${{ vars.DOCS_URL }}
release:
needs: [test-and-build, build_docs]
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.retrieve_version.outputs.new_version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
# Get the version from version.json file and store it in the output file
- name: Get version from version.json
id: retrieve_version
run: |
new_version=$(jq -r '.version' version.json)
if [ -z "$new_version" ]; then
echo "Error: version field is empty or not found in version.json!"
exit 1
fi
echo "new_version=$new_version" >> "$GITHUB_OUTPUT"
# Create tag to the repository by using the version from the output file
- name: Create tag
id: create-tag
run: |
new_version=${{ steps.retrieve_version.outputs.new_version }}
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git tag -a "$new_version" -m "Release version $new_version"
git push origin "$new_version"
echo "new_tag=$new_version" >> "$GITHUB_OUTPUT"
# Create GitHub release
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
new_version=${{ steps.retrieve_version.outputs.new_version }}
new_tag=${{ steps.create-tag.outputs.new_tag }}
sed -n "/## \[$new_version\]/,/## \[/p" CHANGELOG.md | sed '$d' > release_notes.md
gh release create "$new_tag" \
--title "Release ${{ steps.retrieve_version.outputs.new_version }}" \
--notes-file release_notes.md \
--target ${{ github.ref_name }}