Skip to content

Commit d9e87d4

Browse files
committed
ci: trigger builds and releases on version tags
1 parent d0afe2d commit d9e87d4

1 file changed

Lines changed: 66 additions & 19 deletions

File tree

‎.github/workflows/main.yml‎

Lines changed: 66 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ on:
4747
push:
4848
branches:
4949
- main
50+
tags:
51+
- 'v*'
5052

5153
jobs:
5254
fetch-commits:
@@ -66,7 +68,7 @@ jobs:
6668
ksu_commit: ${{ inputs.ksu_commit }}
6769

6870
build-a12-5-10:
69-
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a12-5-10' }}
71+
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a12-5-10' || startsWith(github.ref, 'refs/tags/v') }}
7072
needs: fetch-commits
7173
uses: ./.github/workflows/prepare.yml
7274
with:
@@ -79,7 +81,7 @@ jobs:
7981
secrets: inherit
8082

8183
build-a13-5-10:
82-
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a13-5-10' }}
84+
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a13-5-10' || startsWith(github.ref, 'refs/tags/v') }}
8385
needs: fetch-commits
8486
uses: ./.github/workflows/prepare.yml
8587
with:
@@ -92,7 +94,7 @@ jobs:
9294
secrets: inherit
9395

9496
build-a13-5-15:
95-
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a13-5-15' }}
97+
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a13-5-15' || startsWith(github.ref, 'refs/tags/v') }}
9698
needs: fetch-commits
9799
uses: ./.github/workflows/prepare.yml
98100
with:
@@ -105,7 +107,7 @@ jobs:
105107
secrets: inherit
106108

107109
build-a14-5-15:
108-
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a14-5-15' }}
110+
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a14-5-15' || startsWith(github.ref, 'refs/tags/v') }}
109111
needs: fetch-commits
110112
uses: ./.github/workflows/prepare.yml
111113
with:
@@ -118,7 +120,7 @@ jobs:
118120
secrets: inherit
119121

120122
build-a14-6-1:
121-
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a14-6-1' }}
123+
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a14-6-1' || startsWith(github.ref, 'refs/tags/v') }}
122124
needs: fetch-commits
123125
uses: ./.github/workflows/prepare.yml
124126
with:
@@ -131,7 +133,7 @@ jobs:
131133
secrets: inherit
132134

133135
build-a15-6-6:
134-
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a15-6-6' }}
136+
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a15-6-6' || startsWith(github.ref, 'refs/tags/v') }}
135137
needs: fetch-commits
136138
uses: ./.github/workflows/prepare.yml
137139
with:
@@ -144,7 +146,7 @@ jobs:
144146
secrets: inherit
145147

146148
build-a16-6-12:
147-
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a16-6-12' }}
149+
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a16-6-12' || startsWith(github.ref, 'refs/tags/v') }}
148150
needs: fetch-commits
149151
uses: ./.github/workflows/prepare.yml
150152
with:
@@ -157,7 +159,7 @@ jobs:
157159
secrets: inherit
158160

159161
build-lts:
160-
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'lts' || github.event_name == 'push' }}
162+
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'lts' || (github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v')) || startsWith(github.ref, 'refs/tags/v') }}
161163
needs: fetch-commits
162164
uses: ./.github/workflows/prepare.yml
163165
with:
@@ -170,7 +172,7 @@ jobs:
170172
secrets: inherit
171173

172174
build-custom:
173-
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'custom' }}
175+
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'custom' || startsWith(github.ref, 'refs/tags/v') }}
174176
needs: fetch-commits
175177
uses: ./.github/workflows/prepare.yml
176178
with:
@@ -183,7 +185,7 @@ jobs:
183185
secrets: inherit
184186

185187
build-testing:
186-
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'testing' || github.event_name == 'push' }}
188+
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'testing' || (github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v')) || startsWith(github.ref, 'refs/tags/v') }}
187189
needs: fetch-commits
188190
uses: ./.github/workflows/prepare.yml
189191
with:
@@ -196,7 +198,7 @@ jobs:
196198
secrets: inherit
197199

198200
build-bypass:
199-
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'bypass' }}
201+
if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'bypass' || startsWith(github.ref, 'refs/tags/v') }}
200202
needs: fetch-commits
201203
uses: ./.github/workflows/prepare.yml
202204
with:
@@ -280,7 +282,7 @@ jobs:
280282

281283
release:
282284
runs-on: ubuntu-latest
283-
if: ${{ github.event_name == 'workflow_dispatch' && inputs.release_type != 'Actions' }}
285+
if: ${{ (github.event_name == 'workflow_dispatch' && inputs.release_type != 'Actions') || startsWith(github.ref, 'refs/tags/v') }}
284286
permissions:
285287
contents: write
286288
needs:
@@ -294,6 +296,7 @@ jobs:
294296
- build-lts
295297
- build-custom
296298
- build-bypass
299+
- rej
297300

298301
env:
299302
GH_TOKEN: ${{ github.token }}
@@ -308,6 +311,9 @@ jobs:
308311
309312
failed=0
310313
current_type="${{ inputs.kernel_build_version }}"
314+
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
315+
current_type="all"
316+
fi
311317
312318
check_selected() {
313319
local target="$1"
@@ -355,10 +361,18 @@ jobs:
355361

356362
- name: Checkout code
357363
uses: actions/checkout@v4
364+
with:
365+
fetch-depth: 0
366+
367+
- name: Ensure tag is from main
368+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
369+
run: |
370+
git fetch origin main
371+
git merge-base --is-ancestor "$GITHUB_SHA" "origin/main"
358372
359373
- name: Generate New Tag
360374
id: tag
361-
if: inputs.release_type != 'Actions'
375+
if: ${{ github.event_name == 'workflow_dispatch' && inputs.release_type != 'Actions' }}
362376
run: |
363377
LATEST_TAG=$(gh api repos/${{ github.repository }}/tags --jq '.[0].name' 2>/dev/null || echo "v0.0.0")
364378
if [[ -z "$LATEST_TAG" || "$LATEST_TAG" == "null" ]]; then
@@ -420,14 +434,47 @@ jobs:
420434
-> https://github.com/sidex15/ksu_module_susfs
421435
EOF
422436
437+
- name: Resolve release tag
438+
id: release_tag
439+
run: |
440+
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
441+
echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
442+
else
443+
echo "tag=${{ steps.tag.outputs.new_tag }}" >> "$GITHUB_OUTPUT"
444+
fi
445+
446+
- name: Download AnyKernel3 Artifacts
447+
uses: actions/download-artifact@v4
448+
with:
449+
path: ./downloaded-artifacts
450+
pattern: '*-AnyKernel3'
451+
merge-multiple: false
452+
453+
- name: Download AIO-REJ Artifact
454+
uses: actions/download-artifact@v4
455+
with:
456+
path: ./downloaded-artifacts
457+
pattern: 'AIO-REJ'
458+
merge-multiple: true
459+
460+
- name: Package release zips
461+
run: |
462+
mkdir -p release-assets
463+
for dir in ./downloaded-artifacts/*-AnyKernel3; do
464+
[ -d "$dir" ] || continue
465+
name=$(basename "$dir")
466+
(cd "$dir" && zip -r -q -9 "../../release-assets/${name}.zip" .)
467+
done
468+
if [ -f "./downloaded-artifacts/AIO-REJ.zip" ]; then
469+
cp "./downloaded-artifacts/AIO-REJ.zip" "./release-assets/AIO-REJ.zip"
470+
fi
471+
423472
- name: Create Release
424473
uses: softprops/action-gh-release@v1
425474
with:
426-
tag_name: ${{ steps.tag.outputs.new_tag }}
427-
name: ${{ steps.tag.outputs.new_tag }}
475+
tag_name: ${{ steps.release_tag.outputs.tag }}
476+
name: ${{ steps.release_tag.outputs.tag }}
428477
body_path: release_body.md
429478
draft: false
430-
prerelease: ${{ inputs.release_type == 'Pre-Release' }}
431-
files: |
432-
AnyKernel3/**/*.zip
433-
AIO-REJ.zip
479+
prerelease: ${{ github.event_name == 'workflow_dispatch' && inputs.release_type == 'Pre-Release' }}
480+
files: release-assets/*.zip

0 commit comments

Comments
 (0)