-
Notifications
You must be signed in to change notification settings - Fork 0
200 lines (169 loc) · 5.67 KB
/
merge-dev.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: Create canary release
run-name: Create Canary Release
on:
push:
branches:
- develop
jobs:
lint:
if: contains(github.event.head_commit.message, 'Merge branch')
name: Check Lint of the code (try to auto-fix if possible)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'develop'
fetch-depth: 0
ssh-key: ${{ secrets.BASALT_SSH }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install Dependencies
run: bun install
- name: Run Lint and try to auto-fix if possible
run: |
bun run lint || bun run fix-lint && bun run lint
if [ $? -ne 0 ]; then
echo "Linting failed even after auto-fix. Exiting..."
exit 1
fi
- name: Import GPG key
run: |
echo "${{ secrets.BASALT_GPG }}" | gpg --batch --import
git config --local user.signingkey "$(gpg --list-keys --with-colons | grep '^pub' | cut -d':' -f5 | head -n1)"
git config --local commit.gpgsign true
git config --local tag.gpgsign true
- name: Commit Changes
id: commit_changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions"
if git diff --name-only | grep -E '\.(js|ts|jsx|tsx|css|scss|json|md|yml|yaml)$'; then
git add .
git commit -m "style(🎨): Auto-fix lint issues"
else
echo "No lint-related changes to commit."
fi
- name: Push changes
run: |
git push origin HEAD:develop
test:
if: contains(github.event.head_commit.message, 'Merge branch')
name: Run tests
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'develop'
fetch-depth: 0
ssh-key: ${{ secrets.BASALT_SSH }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install Dependencies
run: bun install
- name: Check if build
run: bun run build
- name: Run tests
run: bun run test
canary:
if: contains(github.event.head_commit.message, 'Merge branch')
name: Create Canary Release
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'develop'
fetch-depth: 0
ssh-key: ${{ secrets.BASALT_SSH }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Fetch tags
run: git fetch --tags --prune
- name: Import GPG key
run: |
echo "${{ secrets.BASALT_GPG }}" | gpg --batch --import
git config --local user.signingkey "$(gpg --list-keys --with-colons | grep '^pub' | cut -d':' -f5 | head -n1)"
git config --local commit.gpgsign true
git config --local tag.gpgsign true
- name: Configure git
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions"
- name: Generate Changelog and bump version
run: bunx changelogen@latest --bump --versionSuffix "canary-$(date +%Y%m%d)-$(git rev-parse --short HEAD)" --release
- name: Sign the tag manually
run: |
LATEST_TAG=$(git describe --tags --abbrev=0)
echo "Signing tag: $LATEST_TAG"
git tag -s "$LATEST_TAG" -m "Signed Canary Release $LATEST_TAG" --force
- name: Push generated tag
run: git push origin --tags HEAD:develop --force
- name: Verify tag signature
run: |
LATEST_TAG=$(git describe --tags --abbrev=0)
git tag -v "$LATEST_TAG"
- name: Extract Changelog additions
id: changelog_diff
run: |
git diff HEAD~1 --unified=0 CHANGELOG.md | grep '^+' | grep -v '++' | sed 's/^+//' > temp.md
echo "Changelog additions:"
cat temp.md
- name: Extract the latest tag
id: get_latest_tag
run: |
LATEST_TAG=$(git describe --tags --abbrev=0)
echo "Latest tag: $LATEST_TAG"
echo "tag_name=$LATEST_TAG" >> $GITHUB_ENV
- name: Create Canary Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Using tag: ${{ env.tag_name }}"
sleep 3
gh release create "${{ env.tag_name }}" \
--title "Canary Release ${{ env.tag_name }}" \
--notes "$(cat temp.md)" \
--prerelease
publish:
if: contains(github.event.head_commit.message, 'Merge branch')
name: Publish Canary Release
runs-on: ubuntu-latest
needs: canary
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'develop'
fetch-depth: 0
ssh-key: ${{ secrets.BASALT_SSH }}
- name: Pull latest changes from develop
run: |
git checkout develop
git pull origin develop --ff-only
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Install Dependencies
run: bun install
- name: Build the project
run: bun run build
- name: Publish the project
run: npm publish --access public --tag canary
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}