From 7988018fdd7d3ceb091faae472e04c8fe80b2b3c Mon Sep 17 00:00:00 2001 From: Maurus Decimus <11444311+mdecimus@users.noreply.github.com> Date: Wed, 21 Oct 2026 11:58:04 +0200 Subject: [PATCH] Add rolling versions --- .github/workflows/build.yml | 65 ++++++++++++++++++++++++++++++++++++- package.json | 3 ++ vite.config.ts | 12 +++++-- 3 files changed, 77 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 870d97d..0416c35 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build and Release on: push: tags: - - 'v*' + - 'v*.*.*' permissions: contents: write @@ -11,6 +11,9 @@ permissions: jobs: build: runs-on: ubuntu-latest + outputs: + major: ${{ steps.version.outputs.major }} + prerelease: ${{ steps.version.outputs.prerelease }} steps: - uses: actions/checkout@v6 @@ -20,6 +23,27 @@ jobs: node-version: 22 cache: npm + - name: Read package version + id: version + run: | + version=$(node -p "require('./package.json').version") + echo "version=$version" >> "$GITHUB_OUTPUT" + echo "major=${version%%.*}" >> "$GITHUB_OUTPUT" + case "$version" in + *-*) echo "prerelease=true" >> "$GITHUB_OUTPUT" ;; + *) echo "prerelease=false" >> "$GITHUB_OUTPUT" ;; + esac + + - name: Check tag matches package version + env: + TAG: ${{ github.ref_name }} + VERSION: ${{ steps.version.outputs.version }} + run: | + if [ "${TAG#v}" != "$VERSION" ]; then + echo "::error::Tag $TAG does not match package.json version $VERSION" + exit 1 + fi + - run: npm ci - run: npm run typecheck @@ -58,6 +82,45 @@ jobs: GH_TOKEN: ${{ github.token }} run: gh release edit "${{ github.ref_name }}" --draft=false --latest --repo "${{ github.repository }}" + rolling: + name: Update rolling major release + needs: [build, publish] + if: needs.build.outputs.prerelease == 'false' + runs-on: ubuntu-latest + concurrency: + group: rolling-v${{ needs.build.outputs.major }} + cancel-in-progress: false + permissions: + contents: write + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + TAG: ${{ github.ref_name }} + ROLLING_TAG: v${{ needs.build.outputs.major }} + ASSET: webui.zip + steps: + - name: Download versioned asset + run: gh release download "$TAG" --pattern "$ASSET" + + - name: Move rolling tag + run: | + if gh api "repos/$GH_REPO/git/ref/tags/$ROLLING_TAG" --silent 2>/dev/null; then + gh api -X PATCH "repos/$GH_REPO/git/refs/tags/$ROLLING_TAG" -f sha="$GITHUB_SHA" -F force=true --silent + else + gh api -X POST "repos/$GH_REPO/git/refs" -f ref="refs/tags/$ROLLING_TAG" -f sha="$GITHUB_SHA" --silent + fi + + - name: Publish rolling release + run: | + title="Stalwart WebUI ${ROLLING_TAG#v}.x" + notes="Tracks the latest ${ROLLING_TAG#v}.x release." + if gh release view "$ROLLING_TAG" >/dev/null 2>&1; then + gh release edit "$ROLLING_TAG" --title "$title" --notes "$notes" --draft=false --prerelease=false --latest=false + gh release upload "$ROLLING_TAG" "$ASSET" --clobber + else + gh release create "$ROLLING_TAG" "$ASSET" --verify-tag --title "$title" --notes "$notes" --latest=false + fi + cleanup: name: Cleanup failed release needs: [build] diff --git a/package.json b/package.json index 43c1a4a..859acb8 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,9 @@ "name": "stalwart-webui", "private": true, "version": "2.0.0", + "stalwart": { + "minServerVersion": "1.0.0" + }, "description": "Stalwart WebUI", "type": "module", "scripts": { diff --git a/vite.config.ts b/vite.config.ts index ad564c3..ad9ac59 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -15,10 +15,18 @@ export default defineConfig({ babel({ presets: [reactCompilerPreset()] }), tailwindcss(), { - name: 'emit-version', + name: 'emit-app-manifest', apply: 'build', generateBundle() { - this.emitFile({ type: 'asset', fileName: 'VERSION', source: `${pkg.version}\n` }) + this.emitFile({ + type: 'asset', + fileName: 'stalwart-app.json', + source: JSON.stringify({ + id: 'webui', + version: pkg.version, + minServerVersion: pkg.stalwart.minServerVersion, + }), + }) }, }, ],