Skip to content

Commit 7599bfa

Browse files
committed
Add Gallery-only release workflow with auto-versioning
- New release-gallery.yml: creates Gallery releases without bumping lib version - Auto-detects lib version, auto-increments gallery suffix (v1.8.0-gallery.1, .2, etc.) - Branch selector (main/alpha) - alpha releases marked as pre-release - Extract shared build logic into _build-gallery.yml reusable workflow - Update release.yml to use shared build workflow
1 parent 48110c9 commit 7599bfa

File tree

3 files changed

+285
-58
lines changed

3 files changed

+285
-58
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build Gallery (Reusable)
2+
3+
# Internal reusable workflow - called by release.yml and release-gallery.yml
4+
# Not meant to be triggered directly
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
branch:
10+
description: 'Branch to build from'
11+
required: false
12+
type: string
13+
default: 'main'
14+
15+
jobs:
16+
build:
17+
strategy:
18+
matrix:
19+
include:
20+
- os: windows-latest
21+
rid: win-x64
22+
artifact_name: Flowery.Gallery-Windows-x64
23+
- os: ubuntu-latest
24+
rid: linux-x64
25+
artifact_name: Flowery.Gallery-Linux-x64
26+
- os: macos-latest
27+
rid: osx-x64
28+
artifact_name: Flowery.Gallery-macOS-x64
29+
- os: macos-latest
30+
rid: osx-arm64
31+
artifact_name: Flowery.Gallery-macOS-arm64
32+
33+
runs-on: ${{ matrix.os }}
34+
permissions:
35+
contents: read
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
with:
40+
ref: ${{ inputs.branch }}
41+
42+
- uses: actions/setup-dotnet@v4
43+
with:
44+
dotnet-version: '9.0.x'
45+
46+
- name: Publish Gallery App
47+
shell: bash
48+
run: |
49+
dotnet publish Flowery.NET.Gallery.Desktop/Flowery.NET.Gallery.Desktop.csproj \
50+
-c Release \
51+
-r ${{ matrix.rid }} \
52+
--self-contained true \
53+
-p:PublishSingleFile=true \
54+
-p:IncludeNativeLibrariesForSelfExtract=true \
55+
-p:EnableCompressionInSingleFile=true \
56+
-o ./publish
57+
58+
- name: Zip Windows artifact
59+
if: matrix.os == 'windows-latest'
60+
run: Compress-Archive -Path ./publish/* -DestinationPath ./${{ matrix.artifact_name }}.zip
61+
shell: pwsh
62+
63+
- name: Tar Linux/macOS artifact
64+
if: matrix.os != 'windows-latest'
65+
run: |
66+
chmod +x ./publish/Flowery.NET.Gallery.Desktop
67+
tar -czvf ./${{ matrix.artifact_name }}.tar.gz -C ./publish .
68+
69+
- name: Upload artifact
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: ${{ matrix.artifact_name }}
73+
path: |
74+
./${{ matrix.artifact_name }}.zip
75+
./${{ matrix.artifact_name }}.tar.gz
76+
if-no-files-found: ignore
77+
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
name: Release Gallery
2+
3+
# MANUAL TRIGGER ONLY - Creates a Gallery-only release (no NuGet publish)
4+
# Automatically determines version from library + increments gallery suffix
5+
# Tags from main: v1.8.0-gallery.1, v1.8.0-gallery.2, etc.
6+
# Tags from alpha: v1.8.0-alpha-gallery.1, v1.8.0-alpha-gallery.2, etc.
7+
8+
on:
9+
workflow_dispatch:
10+
inputs:
11+
branch:
12+
description: 'Branch to release from'
13+
required: true
14+
type: choice
15+
options:
16+
- main
17+
- alpha
18+
default: main
19+
description:
20+
description: 'Optional: What changed in this release?'
21+
required: false
22+
type: string
23+
24+
jobs:
25+
prepare:
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
outputs:
30+
lib_version: ${{ steps.version.outputs.lib_version }}
31+
gallery_suffix: ${{ steps.version.outputs.gallery_suffix }}
32+
tag: ${{ steps.version.outputs.tag }}
33+
display_version: ${{ steps.version.outputs.display_version }}
34+
branch: ${{ steps.version.outputs.branch }}
35+
is_prerelease: ${{ steps.version.outputs.is_prerelease }}
36+
steps:
37+
- uses: actions/checkout@v4
38+
with:
39+
ref: ${{ inputs.branch }}
40+
fetch-depth: 0 # Need full history for tags
41+
42+
- name: Determine version
43+
id: version
44+
run: |
45+
# Get branch from input
46+
BRANCH="${{ inputs.branch }}"
47+
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
48+
echo "Branch: $BRANCH"
49+
50+
# Get library version from csproj
51+
LIB_VERSION=$(grep -oP '(?<=<Version>)[^<]+' Flowery.NET/Flowery.NET.csproj)
52+
echo "lib_version=$LIB_VERSION" >> $GITHUB_OUTPUT
53+
echo "Library version: $LIB_VERSION"
54+
55+
# Build tag pattern based on branch
56+
if [ "$BRANCH" = "main" ]; then
57+
# Main branch: v1.8.0-gallery.N
58+
TAG_PREFIX="v${LIB_VERSION}-gallery."
59+
IS_PRERELEASE="false"
60+
else
61+
# Other branches (e.g., alpha): v1.8.0-alpha-gallery.N
62+
TAG_PREFIX="v${LIB_VERSION}-${BRANCH}-gallery."
63+
IS_PRERELEASE="true"
64+
fi
65+
echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
66+
67+
# Get the highest existing suffix, default to 0 if none exist
68+
HIGHEST=$(git tag -l "${TAG_PREFIX}*" | sed "s/${TAG_PREFIX}//" | sort -n | tail -1)
69+
70+
if [ -z "$HIGHEST" ]; then
71+
NEXT_SUFFIX=1
72+
echo "First gallery release for ${TAG_PREFIX%%.}"
73+
else
74+
NEXT_SUFFIX=$((HIGHEST + 1))
75+
echo "Existing gallery releases found, highest suffix: $HIGHEST"
76+
fi
77+
78+
echo "gallery_suffix=$NEXT_SUFFIX" >> $GITHUB_OUTPUT
79+
80+
TAG="${TAG_PREFIX}${NEXT_SUFFIX}"
81+
if [ "$BRANCH" = "main" ]; then
82+
DISPLAY="${LIB_VERSION}-gallery.${NEXT_SUFFIX}"
83+
else
84+
DISPLAY="${LIB_VERSION}-${BRANCH}-gallery.${NEXT_SUFFIX}"
85+
fi
86+
87+
echo "tag=$TAG" >> $GITHUB_OUTPUT
88+
echo "display_version=$DISPLAY" >> $GITHUB_OUTPUT
89+
90+
echo "Will create release: $TAG (prerelease: $IS_PRERELEASE)"
91+
92+
build-gallery:
93+
needs: prepare
94+
uses: ./.github/workflows/_build-gallery.yml
95+
with:
96+
branch: ${{ inputs.branch }}
97+
permissions:
98+
contents: read
99+
100+
publish:
101+
needs: [prepare, build-gallery]
102+
runs-on: ubuntu-latest
103+
permissions:
104+
contents: write
105+
106+
steps:
107+
- uses: actions/checkout@v4
108+
with:
109+
ref: ${{ inputs.branch }}
110+
111+
- name: Download all artifacts
112+
uses: actions/download-artifact@v4
113+
with:
114+
path: ./release-artifacts
115+
116+
- name: Collect artifacts
117+
run: |
118+
mkdir -p ./final
119+
find ./release-artifacts -name "*.zip" -exec cp {} ./final/ \;
120+
find ./release-artifacts -name "*.tar.gz" -exec cp {} ./final/ \;
121+
echo "=== Release artifacts ==="
122+
ls -la ./final/
123+
124+
- name: Create and push tag
125+
run: |
126+
git config user.name "github-actions[bot]"
127+
git config user.email "github-actions[bot]@users.noreply.github.com"
128+
git tag ${{ needs.prepare.outputs.tag }}
129+
git push origin ${{ needs.prepare.outputs.tag }}
130+
echo "Created tag: ${{ needs.prepare.outputs.tag }}"
131+
132+
- name: Build release notes
133+
run: |
134+
{
135+
# Pre-release warning (if applicable)
136+
if [ "${{ needs.prepare.outputs.is_prerelease }}" = "true" ]; then
137+
echo "> **Pre-release** from \`${{ needs.prepare.outputs.branch }}\` branch - not for production use."
138+
echo ""
139+
fi
140+
141+
echo "## Gallery Demo App Update"
142+
echo ""
143+
144+
# Optional description (if provided)
145+
if [ -n "${{ inputs.description }}" ]; then
146+
echo "### What's Changed"
147+
echo ""
148+
echo "${{ inputs.description }}"
149+
echo ""
150+
fi
151+
152+
echo "This is a **Gallery-only release** containing updates to the demo application."
153+
echo "The underlying Flowery.NET library version remains at **${{ needs.prepare.outputs.lib_version }}**."
154+
echo ""
155+
echo "### Downloads"
156+
echo ""
157+
echo "Self-contained executables - no .NET installation required!"
158+
echo ""
159+
echo "| Platform | Download |"
160+
echo "|----------|----------|"
161+
echo "| Windows x64 | \`Flowery.Gallery-Windows-x64.zip\` |"
162+
echo "| Linux x64 | \`Flowery.Gallery-Linux-x64.tar.gz\` |"
163+
echo "| macOS Intel | \`Flowery.Gallery-macOS-x64.tar.gz\` |"
164+
echo "| macOS Apple Silicon | \`Flowery.Gallery-macOS-arm64.tar.gz\` |"
165+
echo ""
166+
echo "---"
167+
echo ""
168+
echo "> For the NuGet package, see the latest library release: [v${{ needs.prepare.outputs.lib_version }}](https://github.com/${{ github.repository }}/releases/tag/v${{ needs.prepare.outputs.lib_version }})"
169+
} > release_notes.md
170+
171+
echo "=== Release Notes ==="
172+
cat release_notes.md
173+
174+
- name: Load release notes
175+
id: release_body
176+
run: |
177+
{
178+
echo 'body<<EOF'
179+
cat release_notes.md
180+
echo ''
181+
echo 'EOF'
182+
} >> "$GITHUB_OUTPUT"
183+
184+
- name: Create GitHub Release
185+
uses: softprops/action-gh-release@v1
186+
with:
187+
tag_name: ${{ needs.prepare.outputs.tag }}
188+
name: "Gallery ${{ needs.prepare.outputs.display_version }}"
189+
files: ./final/*
190+
body: ${{ steps.release_body.outputs.body }}
191+
generate_release_notes: true
192+
prerelease: ${{ needs.prepare.outputs.is_prerelease == 'true' }}
193+
env:
194+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
195+
196+
- name: Summary
197+
run: |
198+
echo "## Gallery Release Complete!" >> $GITHUB_STEP_SUMMARY
199+
echo "" >> $GITHUB_STEP_SUMMARY
200+
echo "- **Tag:** ${{ needs.prepare.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
201+
echo "- **Branch:** ${{ needs.prepare.outputs.branch }}" >> $GITHUB_STEP_SUMMARY
202+
echo "- **Library Version:** ${{ needs.prepare.outputs.lib_version }}" >> $GITHUB_STEP_SUMMARY
203+
echo "- **Gallery Suffix:** ${{ needs.prepare.outputs.gallery_suffix }}" >> $GITHUB_STEP_SUMMARY
204+
echo "- **Pre-release:** ${{ needs.prepare.outputs.is_prerelease }}" >> $GITHUB_STEP_SUMMARY
205+
echo "- **Release:** ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ needs.prepare.outputs.tag }}" >> $GITHUB_STEP_SUMMARY

.github/workflows/release.yml

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: Release
22

33
# MANUAL TRIGGER ONLY - Creates a new release with NuGet package and Gallery apps
4-
# Go to Actions → Release → Run workflow → Enter version (e.g., 1.0.6)
4+
# Go to Actions → Release → Run workflow → Enter version (e.g., 1.8.0)
55

66
on:
77
workflow_dispatch:
88
inputs:
99
version:
10-
description: 'Version to release (e.g., 1.0.6) - without "v" prefix'
10+
description: 'Version to release (e.g., 1.8.0) - without "v" prefix'
1111
required: true
1212
type: string
1313
skip_nuget:
@@ -92,65 +92,10 @@ jobs:
9292
9393
build-gallery:
9494
needs: validate
95-
strategy:
96-
matrix:
97-
include:
98-
- os: windows-latest
99-
rid: win-x64
100-
artifact_name: Flowery.Gallery-Windows-x64
101-
- os: ubuntu-latest
102-
rid: linux-x64
103-
artifact_name: Flowery.Gallery-Linux-x64
104-
- os: macos-latest
105-
rid: osx-x64
106-
artifact_name: Flowery.Gallery-macOS-x64
107-
- os: macos-latest
108-
rid: osx-arm64
109-
artifact_name: Flowery.Gallery-macOS-arm64
110-
111-
runs-on: ${{ matrix.os }}
95+
uses: ./.github/workflows/_build-gallery.yml
11296
permissions:
11397
contents: read
11498

115-
steps:
116-
- uses: actions/checkout@v4
117-
118-
- uses: actions/setup-dotnet@v4
119-
with:
120-
dotnet-version: '9.0.x'
121-
122-
- name: Publish Gallery App
123-
shell: bash
124-
run: |
125-
dotnet publish Flowery.NET.Gallery.Desktop/Flowery.NET.Gallery.Desktop.csproj \
126-
-c Release \
127-
-r ${{ matrix.rid }} \
128-
--self-contained true \
129-
-p:PublishSingleFile=true \
130-
-p:IncludeNativeLibrariesForSelfExtract=true \
131-
-p:EnableCompressionInSingleFile=true \
132-
-o ./publish
133-
134-
- name: Zip Windows artifact
135-
if: matrix.os == 'windows-latest'
136-
run: Compress-Archive -Path ./publish/* -DestinationPath ./${{ matrix.artifact_name }}.zip
137-
shell: pwsh
138-
139-
- name: Tar Linux/macOS artifact
140-
if: matrix.os != 'windows-latest'
141-
run: |
142-
chmod +x ./publish/Flowery.NET.Gallery.Desktop
143-
tar -czvf ./${{ matrix.artifact_name }}.tar.gz -C ./publish .
144-
145-
- name: Upload artifact
146-
uses: actions/upload-artifact@v4
147-
with:
148-
name: ${{ matrix.artifact_name }}
149-
path: |
150-
./${{ matrix.artifact_name }}.zip
151-
./${{ matrix.artifact_name }}.tar.gz
152-
if-no-files-found: ignore
153-
15499
publish:
155100
needs: [validate, build-library, build-gallery]
156101
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)