17
17
id-token : write
18
18
pull-requests : write
19
19
steps :
20
+ # ref.: https://github.com/sigstore/cosign-installer, v2.1.0
20
21
- name : Install cosign
21
- uses : sigstore/cosign-installer@v2.1.0
22
+ uses : sigstore/cosign-installer@581838fbedd492d2350a9ecd427a95d6de1e5d01
22
23
with :
23
24
cosign-release : ' v1.6.0'
24
25
# ref.: https://github.com/actions/checkout, v3.0.0
@@ -59,11 +60,40 @@ jobs:
59
60
uses : actions/download-artifact@v3.0.0
60
61
with :
61
62
name : sekai-src
62
- - name : Testing SEKAI
63
+ - name : Extract branch name on push
64
+ if : github.event_name == 'push'
65
+ shell : bash
66
+ run : |
67
+ echo "SOURCE_BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
68
+ echo "DESTINATION_BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
69
+ - name : Extract branch name on pull request
70
+ if : github.event_name == 'pull_request'
71
+ env :
72
+ REF_BRANCH : ${{ github.event.pull_request.head.ref }}
73
+ BASE_REF_BRANCH : ${{ github.base_ref }}
74
+ shell : bash
75
+ run : |
76
+ echo "SOURCE_BRANCH=$(echo ${{ env.REF_BRANCH }})" >> $GITHUB_ENV
77
+ echo "DESTINATION_BRANCH=$(echo ${{ env.BASE_REF_BRANCH }})" >> $GITHUB_ENV
78
+ - name : Inspecting & organizing artifacts
63
79
run : |
64
80
echo "(current dir): $PWD" && ls -l ./
65
81
tar xvf ./src.tar.gz
66
82
chmod -Rv 555 ./scripts
83
+ REPOSITORY_NAME="${{ github.event.repository.name }}" && echo "REPOSITORY_NAME=$REPOSITORY_NAME" >> $GITHUB_ENV
84
+ RELEASE_VER=$(./scripts/version.sh) && echo "RELEASE_VER=$RELEASE_VER" >> $GITHUB_ENV
85
+ echo "RELEASE_VER=$RELEASE_VER" >> $GITHUB_ENV
86
+ 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
87
+ - name : Print debug data before testing
88
+ run : |
89
+ echo " Source branch: ${{ env.SOURCE_BRANCH }}"
90
+ echo "Destination branch: ${{ env.DESTINATION_BRANCH }}"
91
+ echo " Event name: ${{ github.event_name }}"
92
+ echo " Repository name: ${{ env.REPOSITORY_NAME }}"
93
+ echo " Release version: ${{ env.RELEASE_VER }}"
94
+ echo " Release exists: ${{ env.RELEASE_EXISTS }}"
95
+ - name : Testing SEKAI
96
+ run : |
67
97
make test
68
98
make install
69
99
sekaid version
76
106
cp -fv ./RELEASE.md ./bin/RELEASE.md
77
107
chmod -Rv 777 ./bin
78
108
echo -e "\n\r\n\r\`\`\`" >> ./bin/RELEASE.md
109
+ echo -e " Release Versions: $RELEASE_VER\n\r" >> ./bin/RELEASE.md
79
110
echo " sekai-darwin-amd64.deb: sha256:$(sha256sum ./bin/sekai-darwin-amd64.deb | awk '{ print $1 }')" >> ./bin/RELEASE.md
80
111
echo " sekai-darwin-arm64.deb: sha256:$(sha256sum ./bin/sekai-darwin-arm64.deb | awk '{ print $1 }')" >> ./bin/RELEASE.md
81
112
echo " sekai-linux-amd64.deb: sha256:$(sha256sum ./bin/sekai-linux-amd64.deb | awk '{ print $1 }')" >> ./bin/RELEASE.md
@@ -109,7 +140,9 @@ jobs:
109
140
echo "(current dir): $PWD" && ls -l ./
110
141
tar xvf ./deb.tar.gz
111
142
chmod -Rv 777 ./
112
- echo "RELEASE_VER=$(grep -Fn -m 1 'Release: ' ./RELEASE.md | rev | cut -d ":" -f1 | rev | xargs | tr -dc '[:alnum:]\-\.' || echo '')" >> $GITHUB_ENV
143
+ RELEASE_VER=$(cat ./RELEASE.md | tac | grep -Fn -m 1 'Release Versions: ' | rev | cut -d ":" -f1 | rev | xargs | tr -dc '[:alnum:]\-\.' || echo '')
144
+ echo "RELEASE_VER=$RELEASE_VER" >> $GITHUB_ENV
145
+ 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
113
146
# Branch name is also a version of the release
114
147
# ref: https://stackoverflow.com/questions/58033366/how-to-get-the-current-branch-within-github-actions
115
148
- name : Extract branch name on push
@@ -129,10 +162,11 @@ jobs:
129
162
echo "DESTINATION_BRANCH=$(echo ${{ env.BASE_REF_BRANCH }} | tr / -)" >> $GITHUB_ENV
130
163
- name : Print debug data before publishing
131
164
run : |
132
- echo "Source branch: ${{ env.SOURCE_BRANCH }}"
133
- echo " Dest. branch: ${{ env.DESTINATION_BRANCH }}"
134
- echo " Event name: ${{ github.event_name }}"
135
- echo " Release ver.: ${{ env.RELEASE_VER }}"
165
+ echo " Source branch: ${{ env.SOURCE_BRANCH }}"
166
+ echo "Destination branch: ${{ env.DESTINATION_BRANCH }}"
167
+ echo " Event name: ${{ github.event_name }}"
168
+ echo " Release version: ${{ env.RELEASE_VER }}"
169
+ echo " Release exists: ${{ env.RELEASE_EXISTS }}"
136
170
- name : Reject on error
137
171
# ref.: https://github.com/andrewslotin/rummelsnuff, v1.1.0
138
172
uses : andrewslotin/rummelsnuff@a0c9c1929f44eefff922aced1ee4dd64eddf12d6
@@ -146,6 +180,7 @@ jobs:
146
180
- name : Publish release
147
181
if : |
148
182
github.event_name == 'push' &&
183
+ ( env.RELEASE_EXISTS == false || env.RELEASE_EXISTS == 'false' ) &&
149
184
( startsWith(env.SOURCE_BRANCH, 'v') && contains(env.SOURCE_BRANCH, '.') && !contains(env.SOURCE_BRANCH, 'rc') && !contains(env.SOURCE_BRANCH, '-') )
150
185
uses : softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
151
186
with :
@@ -168,6 +203,7 @@ jobs:
168
203
- name : Publish pre-release
169
204
if : |
170
205
github.event_name == 'push' &&
206
+ ( env.RELEASE_EXISTS == false || env.RELEASE_EXISTS == 'false' ) &&
171
207
( startsWith(env.SOURCE_BRANCH, 'v') && contains(env.SOURCE_BRANCH, '.') && contains(env.SOURCE_BRANCH, '-') )
172
208
uses : softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
173
209
with :
@@ -186,10 +222,12 @@ jobs:
186
222
./sekai-windows-arm64.exe
187
223
./sekai-utils.sh
188
224
# ref.: https://github.com/hmarr/auto-approve-action, v2.1.0
225
+ # Do NOT approve IF release exists and the source branch is NOT a version branch
189
226
- name : Approve pull request on success
190
227
uses : hmarr/auto-approve-action@5d04a5ca6da9aeb8ca9f31a5239b96fc3e003029
191
228
if : |
192
229
( github.event_name == 'pull_request' ) &&
230
+ (( env.RELEASE_EXISTS == false || env.RELEASE_EXISTS == 'false' ) || env.SOURCE_BRANCH == env.RELEASE_VER) &&
193
231
( env.SOURCE_BRANCH == env.RELEASE_VER || env.DESTINATION_BRANCH == env.RELEASE_VER )
194
232
with :
195
233
github-token : " ${{ secrets.GITHUB_TOKEN }}"
0 commit comments