|
| 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 |
0 commit comments