@@ -16,18 +16,22 @@ jobs:
16
16
id-token : write
17
17
pull-requests : write
18
18
container :
19
- image : ghcr.io/kiracore/docker/base-image:v0.8.0.0
19
+ image : ghcr.io/kiracore/docker/base-image:v0.9.1.1
20
20
steps :
21
+ # Work around https://github.com/actions/checkout/issues/760
22
+ - name : Add safe.directory
23
+ run : |
24
+ git config --global --add safe.directory /github/workspace
25
+ git config --global --add safe.directory $PWD
26
+ # ref.: https://github.com/actions/checkout, v3.0.0
21
27
- name : Checkout repository
22
28
uses : actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
23
- - name : Verify repo content
29
+ - name : Checking dependency versions & packaging source files
24
30
run : |
25
31
echo "(current dir): $PWD" && ls -l ./
26
32
cd ../ && tar -czvf src.tar.gz -C ./sekai . && cp ./src.tar.gz ./sekai/src.tar.gz
27
33
cd ./sekai
28
- - name : Checking dependency versions
29
- run : |
30
- . /etc/profile && echo "Utils Version: $(utilsVersion)"
34
+ . /etc/profile && echo "Utils Version: $(bashUtilsVersion)"
31
35
go version
32
36
echo "ENVS: $(env)"
33
37
echo "HOME: $HOME"
@@ -50,20 +54,24 @@ jobs:
50
54
- name : Inspecting & organizing artifacts
51
55
run : |
52
56
echo "(current dir): $PWD" && ls -l ./
53
- tar xvf ./src.tar.gz
54
57
chmod -Rv 555 ./scripts
58
+ RELEASE_VER="$(./scripts/version.sh)" && echo "RELEASE_VER=$RELEASE_VER" >> $GITHUB_ENV
55
59
REPOSITORY_NAME="${{ github.event.repository.name }}" && echo "REPOSITORY_NAME=$REPOSITORY_NAME" >> $GITHUB_ENV
56
- RELEASE_VER=$(./scripts/version.sh) && echo "RELEASE_VER=$RELEASE_VER" >> $GITHUB_ENV
57
- echo "RELEASE_VER=$RELEASE_VER" >> $GITHUB_ENV
58
60
git ls-remote https://github.com/kiracore/$REPOSITORY_NAME | egrep -q "refs/tags/${RELEASE_VER}$" && echo "RELEASE_EXISTS=true" >> $GITHUB_ENV || echo "RELEASE_EXISTS=false" >> $GITHUB_ENV
61
+ if [[ "$RELEASE_VER" =~ $VERSION_REGEX ]] && [[ "$SOURCE_BRANCH" =~ $VERSION_REGEX ]] && [ "$SOURCE_BRANCH" != "$RELEASE_VER" ] ; then
62
+ echo "ERROR: Version branch name MUST be the same as the app version, run scripts/version.sh to check app version!"
63
+ exit 1
64
+ else
65
+ echo "INFO: Variables setup succeeded"
66
+ fi
59
67
- name : Print debug data before testing
60
68
run : |
61
69
echo " Source branch: ${{ env.SOURCE_BRANCH }}"
62
70
echo "Destination branch: ${{ env.DESTINATION_BRANCH }}"
63
- echo " Event name: ${{ github.event_name }}"
64
- echo " Repository name: ${{ env.REPOSITORY_NAME }}"
65
- echo " Release version: ${{ env.RELEASE_VER }}"
66
- echo " Release exists: ${{ env.RELEASE_EXISTS }}"
71
+ echo " Event name: ${{ github.event_name }}"
72
+ echo " Repository name: ${{ env.REPOSITORY_NAME }}"
73
+ echo " Release version: ${{ env.RELEASE_VER }}"
74
+ echo " Release exists: ${{ env.RELEASE_EXISTS }}"
67
75
- name : Testing SEKAI
68
76
run : |
69
77
make test
87
95
echo " sekai-linux-arm64.deb: sha256:$(sha256sum ./bin/sekai-linux-arm64.deb | awk '{ print $1 }')" >> ./bin/RELEASE.md
88
96
echo "sekai-windows-amd64.exe: sha256:$(sha256sum ./bin/sekai-windows-amd64.exe | awk '{ print $1 }')" >> ./bin/RELEASE.md
89
97
echo "sekai-windows-arm64.exe: sha256:$(sha256sum ./bin/sekai-windows-arm64.exe | awk '{ print $1 }')" >> ./bin/RELEASE.md
90
- echo " sekai-utils.sh: sha256:$(sha256sum ./bin/sekai-utils.sh | awk '{ print $1 }')" >> ./bin/RELEASE.md
91
98
echo " source-code.tar.gz: sha256:$(sha256sum ./bin/source-code.tar.gz | awk '{ print $1 }')" >> ./bin/RELEASE.md
99
+ echo " sekai-utils.sh: sha256:$(sha256sum ./bin/sekai-utils.sh | awk '{ print $1 }')" >> ./bin/RELEASE.md
100
+ echo " sekai-env.sh: sha256:$(sha256sum ./bin/sekai-env.sh | awk '{ print $1 }')" >> ./bin/RELEASE.md
92
101
echo -e "\`\`\`" >> ./bin/RELEASE.md
93
102
tar -czvf deb.tar.gz -C ./bin .
94
103
- name : Uploading artifacts
@@ -106,6 +115,12 @@ jobs:
106
115
id-token : write
107
116
pull-requests : write
108
117
steps :
118
+ # Install the cosign tool
119
+ # ref.: https://github.com/sigstore/cosign-installer, v2.2.0
120
+ - name : Install cosign
121
+ uses : sigstore/cosign-installer@d6a3abf1bdea83574e28d40543793018b6035605
122
+ with :
123
+ cosign-release : ' v1.7.2'
109
124
- name : Download artifacts
110
125
uses : actions/download-artifact@v3.0.0
111
126
with :
@@ -117,31 +132,36 @@ jobs:
117
132
chmod -Rv 777 ./
118
133
RELEASE_VER=$(cat ./RELEASE.md | tac | grep -Fn -m 1 'Release Versions: ' | rev | cut -d ":" -f1 | rev | xargs | tr -dc '[:alnum:]\-\.' || echo '')
119
134
echo "RELEASE_VER=$RELEASE_VER" >> $GITHUB_ENV
120
- git ls-remote https://github.com/kiracore/${{ github.event.repository.name }} | egrep -q "refs/tags/${RELEASE_VER}$" && echo "RELEASE_EXISTS=true" >> $GITHUB_ENV || echo "RELEASE_EXISTS=false" >> $GITHUB_ENV
135
+ REPOSITORY_NAME="${{ github.event.repository.name }}"
136
+ echo "REPOSITORY_NAME=$REPOSITORY_NAME" >> $GITHUB_ENV
137
+ git ls-remote https://github.com/kiracore/$REPOSITORY_NAME | egrep -q "refs/tags/${RELEASE_VER}$" && echo "RELEASE_EXISTS=true" >> $GITHUB_ENV || echo "RELEASE_EXISTS=false" >> $GITHUB_ENV
138
+ [[ "$RELEASE_VER" == *"-rc"* ]] && echo "PRE_RELEASE=true" >> $GITHUB_ENV || echo "PRE_RELEASE=false" >> $GITHUB_ENV
121
139
# Branch name is also a version of the release
122
140
# ref: https://stackoverflow.com/questions/58033366/how-to-get-the-current-branch-within-github-actions
123
141
- name : Extract branch name on push
124
142
if : github.event_name == 'push'
125
143
shell : bash
126
144
run : |
127
- echo "SOURCE_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | tr / - )" >> $GITHUB_ENV
128
- echo "DESTINATION_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | tr / - )" >> $GITHUB_ENV
145
+ echo "SOURCE_BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
146
+ echo "DESTINATION_BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
129
147
- name : Extract branch name on pull request
130
148
if : github.event_name == 'pull_request'
131
149
env :
132
150
REF_BRANCH : ${{ github.event.pull_request.head.ref }}
133
151
BASE_REF_BRANCH : ${{ github.base_ref }}
134
152
shell : bash
135
153
run : |
136
- echo "SOURCE_BRANCH=$(echo ${{ env.REF_BRANCH }} | tr / - )" >> $GITHUB_ENV
137
- echo "DESTINATION_BRANCH=$(echo ${{ env.BASE_REF_BRANCH }} | tr / - )" >> $GITHUB_ENV
154
+ echo "SOURCE_BRANCH=$(echo ${{ env.REF_BRANCH }})" >> $GITHUB_ENV
155
+ echo "DESTINATION_BRANCH=$(echo ${{ env.BASE_REF_BRANCH }})" >> $GITHUB_ENV
138
156
- name : Print debug data before publishing
139
157
run : |
140
- echo " Source branch: ${{ env.SOURCE_BRANCH }}"
141
- echo "Destination branch: ${{ env.DESTINATION_BRANCH }}"
142
- echo " Event name: ${{ github.event_name }}"
143
- echo " Release version: ${{ env.RELEASE_VER }}"
144
- echo " Release exists: ${{ env.RELEASE_EXISTS }}"
158
+ echo " Source branch: ${{ env.SOURCE_BRANCH }}"
159
+ echo " Dest. branch: ${{ env.DESTINATION_BRANCH }}"
160
+ echo " Repo Name: ${{ env.REPOSITORY_NAME }}"
161
+ echo " Event name: ${{ github.event_name }}"
162
+ echo " Release ver.: ${{ env.RELEASE_VER }}"
163
+ echo "Release exists: ${{ env.RELEASE_EXISTS }}"
164
+ echo " Pre-release: ${{ env.PRE_RELEASE }}"
145
165
- name : Reject on error
146
166
# ref.: https://github.com/andrewslotin/rummelsnuff, v1.1.0
147
167
uses : andrewslotin/rummelsnuff@a0c9c1929f44eefff922aced1ee4dd64eddf12d6
@@ -152,59 +172,59 @@ jobs:
152
172
access_token : ${{ secrets.GITHUB_TOKEN }}
153
173
# ref: https://github.com/softprops/action-gh-release, v0.1.14
154
174
# Release on merge only (push action) - this should run only once
155
- - name : Publish release
175
+ - name : Signing release files
156
176
if : |
157
177
github.event_name == 'push' &&
158
178
( env.RELEASE_EXISTS == false || env.RELEASE_EXISTS == 'false' ) &&
159
- ( startsWith(env.SOURCE_BRANCH, 'v') && contains(env.SOURCE_BRANCH, '.') && !contains(env.SOURCE_BRANCH, 'rc') && !contains(env.SOURCE_BRANCH, '-') )
160
- uses : softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
161
- with :
162
- body_path : RELEASE.md
163
- tag_name : ${{ env.SOURCE_BRANCH }}
164
- name : ${{ env.SOURCE_BRANCH }}
165
- prerelease : false
166
- draft : false
167
- fail_on_unmatched_files : true
168
- files : |
169
- ./sekai-linux-amd64.deb
170
- ./sekai-linux-arm64.deb
171
- ./sekai-darwin-amd64.deb
172
- ./sekai-darwin-arm64.deb
173
- ./sekai-windows-amd64.exe
174
- ./sekai-windows-arm64.exe
175
- ./sekai-utils.sh
176
- ./source-code.tar.gz
179
+ ( startsWith(env.SOURCE_BRANCH, 'v') && contains(env.SOURCE_BRANCH, '.') )
180
+ shell : bash
181
+ env :
182
+ KEY : ${{ secrets.COSIGN_PRIVATE_KEY }}
183
+ COSIGN_PASSWORD : ${{ secrets.COSIGN_PASSWORD }}
184
+ run : |
185
+ echo "$KEY" > ../cosign.key
186
+ for FILE in *; do FILE_NAME=$(basename $FILE); cosign sign-blob --key=../cosign.key --output-signature=./${FILE_NAME}.sig ./$FILE_NAME; done
187
+ rm -fv ../cosign.key
177
188
# ref: https://github.com/softprops/action-gh-release, v0.1.14
178
189
# Release on merge only (push action) - this should run only once
179
- - name : Publish pre- release
190
+ - name : Publish release
180
191
if : |
181
192
github.event_name == 'push' &&
182
193
( env.RELEASE_EXISTS == false || env.RELEASE_EXISTS == 'false' ) &&
183
- ( startsWith(env.SOURCE_BRANCH, 'v') && contains(env.SOURCE_BRANCH, '.') && contains(env.SOURCE_BRANCH, '-') )
194
+ ( startsWith(env.SOURCE_BRANCH, 'v') && contains(env.SOURCE_BRANCH, '.') )
184
195
uses : softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
185
196
with :
186
197
body_path : RELEASE.md
187
198
tag_name : ${{ env.SOURCE_BRANCH }}
188
199
name : ${{ env.SOURCE_BRANCH }}
189
- prerelease : true
200
+ prerelease : ${{ env.PRE_RELEASE }}
190
201
draft : false
191
202
fail_on_unmatched_files : true
192
203
files : |
193
204
./sekai-linux-amd64.deb
205
+ ./sekai-linux-amd64.deb.sig
194
206
./sekai-linux-arm64.deb
207
+ ./sekai-linux-arm64.deb.sig
195
208
./sekai-darwin-amd64.deb
209
+ ./sekai-darwin-amd64.deb.sig
196
210
./sekai-darwin-arm64.deb
211
+ ./sekai-darwin-arm64.deb.sig
197
212
./sekai-windows-amd64.exe
213
+ ./sekai-windows-amd64.exe.sig
198
214
./sekai-windows-arm64.exe
215
+ ./sekai-windows-arm64.exe.sig
199
216
./sekai-utils.sh
217
+ ./sekai-utils.sh.sig
218
+ ./sekai-env.sh
219
+ ./sekai-env.sh.sig
200
220
./source-code.tar.gz
221
+ ./source-code.tar.gz.sig
201
222
# ref.: https://github.com/hmarr/auto-approve-action, v2.1.0
202
223
# Do NOT approve IF release exists and the source branch is NOT a version branch
203
224
- name : Approve pull request on success
204
225
uses : hmarr/auto-approve-action@5d04a5ca6da9aeb8ca9f31a5239b96fc3e003029
205
226
if : |
206
227
( github.event_name == 'pull_request' ) &&
207
- (( env.RELEASE_EXISTS == false || env.RELEASE_EXISTS == 'false' ) || env.SOURCE_BRANCH == env.RELEASE_VER) &&
208
228
( env.SOURCE_BRANCH == env.RELEASE_VER || env.DESTINATION_BRANCH == env.RELEASE_VER )
209
229
with :
210
230
github-token : " ${{ secrets.GITHUB_TOKEN }}"
@@ -213,15 +233,20 @@ jobs:
213
233
run : |
214
234
rm -rfv ./*
215
235
echo "(current dir): $PWD" && ls -l ./
236
+ # Work around https://github.com/actions/checkout/issues/760
237
+ - name : Add safe.directory
238
+ run : |
239
+ git config --global --add safe.directory /github/workspace
240
+ git config --global --add safe.directory $PWD
216
241
# ref.: https://github.com/actions/checkout, v3.0.0
217
242
- name : Checkout repository
218
243
uses : actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
219
244
- name : Create PR from a version branch to latest
220
- # ref: https://github.com/repo-sync/pull-request
245
+ # ref. repo-sync/pull-request is broken, using cea2aj/pull-request instead
246
+ uses : cea2aj/pull-request@84eb0c3478f13651e5649367941b867ca02d7926
221
247
if : |
222
248
github.event_name == 'push' &&
223
249
( startsWith(env.SOURCE_BRANCH, 'v') && contains(env.SOURCE_BRANCH, '.') )
224
- uses : repo-sync/pull-request@5ba2c80b97c87b9174c1548141b7acd80f6376e1
225
250
with :
226
251
github_token : ${{ secrets.REPO_ACCESS }}
227
252
source_branch : ${{ env.SOURCE_BRANCH }}
0 commit comments