Skip to content

Commit b1ae513

Browse files
committed
Merge branch 'master' into dev
2 parents 833e4c0 + a67c620 commit b1ae513

File tree

3 files changed

+260
-312
lines changed

3 files changed

+260
-312
lines changed

.github/workflows/build.yml

Lines changed: 260 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: Build
22

3-
concurrency:
4-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
5-
cancel-in-progress: true
6-
73
on:
84
push:
95
tags:
@@ -26,17 +22,163 @@ permissions:
2622
jobs:
2723
compute-version:
2824
name: Compute version
29-
uses: ./.github/workflows/version.yml
30-
secrets: inherit
31-
32-
build:
33-
name: Build and test
3425
runs-on: windows-latest
35-
needs: compute-version
26+
concurrency:
27+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
28+
cancel-in-progress: true
29+
outputs:
30+
doRelease: ${{ steps.vars.outputs.doRelease }}
31+
verMajor: ${{ steps.vars.outputs.verMajor }}
32+
verMinor: ${{ steps.vars.outputs.verMinor }}
33+
verRelease: ${{ steps.vars.outputs.verRelease }}
34+
verBuild: ${{ steps.vars.outputs.verBuild }}
35+
verRevision: ${{ steps.vars.outputs.verRevision }}
36+
verLong: ${{ steps.vars.outputs.verLong }}
37+
verRaw: ${{ steps.vars.outputs.verRaw }}
38+
verShort: ${{ steps.vars.outputs.verShort }}
39+
verDebug: ${{ steps.vars.outputs.verDebug }}
40+
verOldTag: ${{ steps.vars.outputs.verOldTag }}
41+
verTag: ${{ steps.vars.outputs.verTag }}
42+
verTitle: ${{ steps.vars.outputs.verTitle }}
43+
3644
steps:
3745
- name: Checkout
38-
uses: actions/checkout@v3
39-
46+
uses: actions/checkout@v4
47+
with:
48+
fetch-depth: 0
49+
50+
- name: Compute variables
51+
id: vars
52+
shell: pwsh
53+
run: |
54+
Set-StrictMode -Version Latest
55+
$ErrorActionPreference = 'Stop'
56+
57+
# Ensure tags exist locally
58+
git fetch --tags --force | Out-Null
59+
60+
$ref = "${env:GITHUB_REF}" # e.g. refs/tags/version1.2.3 or refs/heads/dev
61+
$refName = "${env:GITHUB_REF_NAME}" # e.g. version1.2.3 or dev
62+
$isTag = $ref.StartsWith("refs/tags/")
63+
$isDev = ($ref -eq "refs/heads/dev")
64+
65+
$H = (git rev-parse HEAD).Trim()
66+
67+
function Set-Var([string]$name, [string]$value) {
68+
# For later steps in the SAME job
69+
"$name=$value" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
70+
# For later jobs (job outputs)
71+
"$name=$value" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
72+
}
73+
74+
# Defaults
75+
Set-Var "doRelease" "false"
76+
Set-Var "verMajor" ""
77+
Set-Var "verMinor" ""
78+
Set-Var "verRelease" ""
79+
Set-Var "verBuild" ""
80+
Set-Var "verRevision" ""
81+
Set-Var "verLong" ""
82+
Set-Var "verRaw" ""
83+
Set-Var "verShort" ""
84+
Set-Var "verDebug" ""
85+
Set-Var "verOldTag" ""
86+
Set-Var "verTag" ""
87+
Set-Var "verTitle" ""
88+
89+
90+
# Case 1: Tag versionX.Y.Z
91+
if ($isTag -and ($refName -match '^version(\d+)\.(\d+)\.(\d+)$')) {
92+
$X = $Matches[1]
93+
$Y = $Matches[2]
94+
$Z = $Matches[3]
95+
96+
Set-Var "verMajor" $X
97+
Set-Var "verMinor" $Y
98+
Set-Var "verRelease" $Z
99+
Set-Var "verBuild" "0"
100+
Set-Var "verRevision" $H
101+
102+
$raw = "$X.$Y.$Z"
103+
Set-Var "verRaw" $raw
104+
Set-Var "verShort" $raw
105+
Set-Var "verLong" $raw
106+
107+
Set-Var "verDebug" "false"
108+
Set-Var "verOldTag" ""
109+
Set-Var "verTag" $refName
110+
111+
Set-Var "doRelease" "true"
112+
Set-Var "verTitle" "version $raw"
113+
114+
exit 0
115+
}
116+
117+
# Case 2: dev branch
118+
if ($isDev) {
119+
# Find latest nightlyN tag (max N)
120+
$nightlyTags = git tag --list 'nightly*'
121+
$maxN = -1
122+
foreach ($t in $nightlyTags) {
123+
if ($t -match '^nightly(\d+)$') {
124+
$n = [int]$Matches[1]
125+
if ($n -gt $maxN) { $maxN = $n }
126+
}
127+
}
128+
if ($maxN -lt 0) { $maxN = 0 } # if none exists, start from 0 so M becomes 1
129+
$M = $maxN + 1
130+
131+
# Find latest versionX.Y.Z tag by numeric comparison (major,minor,release)
132+
$versionTags = git tag --list 'version*'
133+
$best = $null
134+
foreach ($t in $versionTags) {
135+
if ($t -match '^version(\d+)\.(\d+)\.(\d+)$') {
136+
$maj = [int]$Matches[1]
137+
$min = [int]$Matches[2]
138+
$rel = [int]$Matches[3]
139+
$obj = [pscustomobject]@{ Tag=$t; Major=$maj; Minor=$min; Release=$rel }
140+
if (-not $best) {
141+
$best = $obj
142+
} else {
143+
if ($obj.Major -gt $best.Major -or
144+
($obj.Major -eq $best.Major -and $obj.Minor -gt $best.Minor) -or
145+
($obj.Major -eq $best.Major -and $obj.Minor -eq $best.Minor -and $obj.Release -gt $best.Release)) {
146+
$best = $obj
147+
}
148+
}
149+
}
150+
}
151+
152+
if (-not $best) {
153+
throw "No versionX.Y.Z tag found. Create at least one version tag (e.g. version1.0.0)."
154+
}
155+
156+
$X = $best.Major
157+
$Y = $best.Minor
158+
$Z = $best.Release
159+
160+
Set-Var "verMajor" "$X"
161+
Set-Var "verMinor" "$Y"
162+
Set-Var "verRelease" "$Z"
163+
Set-Var "verBuild" "$M"
164+
Set-Var "verRevision" $H
165+
166+
Set-Var "verLong" "$X.$Y.$Z nightly build $M"
167+
Set-Var "verRaw" "$X.$Y.$Z"
168+
Set-Var "verShort" "$X.$Y.$Z`_nightly$M"
169+
Set-Var "verDebug" "true"
170+
Set-Var "verOldTag" "nightly$maxN"
171+
172+
Set-Var "verTag" "nightly$M"
173+
174+
Set-Var "verTitle" "(PREVIEW) version $X.$Y.$Z nightly $M"
175+
176+
Set-Var "doRelease" "true"
177+
exit 0
178+
}
179+
180+
# Other cases: doRelease stays false
181+
exit 0
40182
- name: Prepare version info property file
41183
shell: pwsh
42184
run: |
@@ -53,7 +195,17 @@ jobs:
53195
uses: actions/upload-artifact@v4
54196
with:
55197
name: version_properties
56-
path: version.properties
198+
path: version.properties
199+
build:
200+
name: Build and test
201+
runs-on: windows-latest
202+
concurrency:
203+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
204+
cancel-in-progress: true
205+
needs: compute-version
206+
steps:
207+
- name: Checkout
208+
uses: actions/checkout@v3
57209

58210
- name: Set up JDK
59211
uses: actions/setup-java@v4
@@ -122,6 +274,9 @@ jobs:
122274
exe:
123275
name: Generate EXE
124276
runs-on: ubuntu-latest
277+
concurrency:
278+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
279+
cancel-in-progress: true
125280
needs: compute-version
126281
if: needs.compute-version.outputs.doRelease == 'true'
127282
steps:
@@ -267,6 +422,9 @@ jobs:
267422
sign_and_msi:
268423
name: Code signing, MSI installer
269424
runs-on: windows-latest
425+
concurrency:
426+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
427+
cancel-in-progress: true
270428
needs:
271429
- compute-version
272430
- build
@@ -609,6 +767,9 @@ jobs:
609767
packages:
610768
name: Create packages
611769
runs-on: ubuntu-latest
770+
concurrency:
771+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
772+
cancel-in-progress: true
612773
needs:
613774
- compute-version
614775
- build
@@ -686,4 +847,89 @@ jobs:
686847
with:
687848
name: packages
688849
path: releases
689-
850+
851+
deploy:
852+
name: Deploy to GitHub
853+
runs-on: ubuntu-latest
854+
if: needs.compute-version.outputs.doRelease == 'true'
855+
# This one is different from others
856+
concurrency:
857+
group: ${{ github.workflow }}-${{ github.ref }}
858+
cancel-in-progress: false
859+
needs:
860+
- compute-version
861+
steps:
862+
- name: Checkout
863+
uses: actions/checkout@v3
864+
865+
- name: Set up PHP
866+
run: |
867+
sudo apt-get update -y -qq
868+
sudo apt-get install -y -qq php
869+
870+
- name: Download packages artifact
871+
uses: actions/download-artifact@v4
872+
with:
873+
name: packages
874+
path: releases/
875+
876+
- name: Download lib javadoc artifact
877+
uses: actions/download-artifact@v4
878+
with:
879+
name: lib_javadoc
880+
path: releases/
881+
882+
- name: Generate nightly release description
883+
if: needs.compute-version.outputs.verDebug == 'true'
884+
run: php cicd_scripts/format_release_info.php -filever "${{ needs.compute-version.outputs.verShort }}" Unreleased ${{ needs.compute-version.outputs.verTag }} ./CHANGELOG.md "${{ env.CICD_REPO_SLUG }}" > ./release_notes.md
885+
886+
- name: Generate release description
887+
if: needs.compute-version.outputs.verDebug == 'false'
888+
run: php cicd_scripts/format_release_info.php -filever "${{ needs.compute-version.outputs.verShort }}" "${{ needs.compute-version.outputs.verShort }}" ${{ needs.compute-version.outputs.verTag }} ./CHANGELOG.md "${{ env.CICD_REPO_SLUG }}" > ./release_notes.md
889+
890+
- name: Upload release notes artifact
891+
uses: actions/upload-artifact@v4
892+
with:
893+
name: release_notes
894+
path: ./release_notes.md
895+
896+
- name: Create tag
897+
if: needs.compute-version.outputs.verDebug == 'true'
898+
run: |
899+
TAG="${{ needs.compute-version.outputs.verTag }}"
900+
git fetch --tags --force
901+
902+
if git rev-parse "$TAG" >/dev/null 2>&1; then
903+
echo "Tag $TAG already exists -> skipping tag creation."
904+
exit 0
905+
fi
906+
907+
git config user.name "github-actions[bot]"
908+
git config user.email "github-actions[bot]@users.noreply.github.com"
909+
910+
git tag "$TAG"
911+
git push origin "$TAG"
912+
913+
- name: Create GitHub Release + upload assets
914+
uses: softprops/action-gh-release@v2
915+
with:
916+
tag_name: ${{ needs.compute-version.outputs.verTag }}
917+
name: ${{ needs.compute-version.outputs.verTitle }}
918+
body_path: ./release_notes.md
919+
preserve_order: true
920+
prerelease: ${{ needs.compute-version.outputs.verDebug == 'true'}}
921+
fail_on_unmatched_files: true
922+
files: |
923+
releases/ffdec_${{ needs.compute-version.outputs.verShort }}.msi
924+
releases/ffdec_${{ needs.compute-version.outputs.verShort }}.zip
925+
releases/ffdec_${{ needs.compute-version.outputs.verShort }}.deb
926+
releases/ffdec_${{ needs.compute-version.outputs.verShort }}.pkg
927+
releases/ffdec_${{ needs.compute-version.outputs.verShort }}_macosx.zip
928+
releases/ffdec_lib_${{ needs.compute-version.outputs.verShort }}.zip
929+
releases/ffdec_lib_javadoc_${{ needs.compute-version.outputs.verShort }}.zip
930+
- name: Remove old nightly
931+
if: needs.compute-version.outputs.verDebug == 'true'
932+
env:
933+
GH_TOKEN: ${{ github.token }}
934+
run: |
935+
gh release delete ${{needs.compute-version.outputs.verOldTag}} --yes --cleanup-tag

0 commit comments

Comments
 (0)