-
Notifications
You must be signed in to change notification settings - Fork 32
135 lines (119 loc) · 4.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
---
name: "Auto Release"
on:
push:
branches:
- 'main'
- 'master'
paths:
- 'package.json'
jobs:
build:
name: "Build Release"
runs-on: "ubuntu-latest"
steps:
- name: "✏️ Checkout code"
uses: actions/checkout@v4
with:
path: './'
- name: "🏷️ Get version tag"
id: set_var
run: echo "COMPONENT_VERSION=$(grep version package.json | cut -d ":" -f 2 | sed -e 's/[^0-9\.beta\-]//g')" >> $GITHUB_ENV
- name: "🏷️ Check if tag exists already"
uses: mukunku/[email protected]
id: "check_tag"
with:
tag: "v${{ env.COMPONENT_VERSION }}"
- name: "❌ Cancel if tag is already present"
run: |
echo "Tag already present: v${{ env.COMPONENT_VERSION }}. Not creating a new release"
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: steps.check_tag.outputs.exists == 'true'
- name: "👷 Build using Node.js"
uses: actions/setup-node@v3
with:
node-version: '20.x'
- run: npm ci
- run: npm run build --if-present
- name: "📝 Commit files"
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git status
git commit -m "Add new build" -a
- name: "⬆️ Push changes"
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
auto-release:
name: "Auto Release"
runs-on: "ubuntu-latest"
needs: build
steps:
- name: "⬇️ Checkout new code"
uses: actions/checkout@v4
with:
ref: master
path: './'
- name: "🏷️ Get version tag"
id: set_var
run: echo "COMPONENT_VERSION=$(grep version package.json | cut -d ":" -f 2 | sed -e 's/[^0-9\.beta\-]//g')" >> $GITHUB_ENV
- name: "🏷️ Get git sha"
id: set_var_2
run: echo "CURRENT_SHA=$(git log -1 --format='%H')" >> $GITHUB_ENV
- name: "🏷️ Check if tag exists already"
uses: mukunku/[email protected]
id: "check_tag"
with:
tag: "v${{ env.COMPONENT_VERSION }}"
- name: "❌ Cancel if tag is already present"
run: |
echo "Tag already present: v${{ env.COMPONENT_VERSION }}. Not creating a new release"
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: steps.check_tag.outputs.exists == 'true'
- name: "🗝️ Get previous release version"
id: last_release
uses: InsonusK/[email protected]
with:
myToken: ${{ github.token }}
exclude_types: "draft|prerelease"
- name: "🏷️ Create new tag"
uses: rickstaa/action-create-tag@v1
id: "tag_create"
with:
tag: "v${{ env.COMPONENT_VERSION }}"
commit_sha: "${{ env.CURRENT_SHA }}"
tag_exists_error: false
message: "Version ${{ env.COMPONENT_VERSION }}"
- name: "🗒️ Generate release changelog"
id: changelog
uses: heinrichreimer/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
sinceTag: ${{ steps.last_release.outputs.tag_name }}
headerLabel: "# Notable changes since ${{ steps.last_release.outputs.tag_name }}"
stripGeneratorNotice: true
- name: 👍 Create Stable release
uses: softprops/action-gh-release@v1
with:
prerelease: false
body: "${{ steps.changelog.outputs.changelog }}"
name: "Version ${{ env.COMPONENT_VERSION }}"
tag_name: "v${{ env.COMPONENT_VERSION }}"
target_commitish: "${{ env.CURRENT_SHA }}"
if: contains(env.COMPONENT_VERSION, 'beta') == false
- name: 🤞 Create Beta release
uses: softprops/action-gh-release@v1
with:
prerelease: true
body: "${{ steps.changelog.outputs.changelog }}"
name: "Version ${{ env.COMPONENT_VERSION }}"
tag_name: "v${{ env.COMPONENT_VERSION }}"
target_commitish: "${{ env.CURRENT_SHA }}"
if: contains(env.COMPONENT_VERSION, 'beta') == true