Skip to content

Commit 022c44d

Browse files
committed
fix: revert to a single workflow and trigger on tags
1 parent 44934ef commit 022c44d

2 files changed

Lines changed: 44 additions & 43 deletions

File tree

.github/workflows/build-n-tag.yaml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
name: Release
22

33
# Triggered by pushing a semver tag (e.g. v2.1.3, v2.1.3-beta.1).
4-
# Creates a GitHub Release with auto-generated notes. Marks it as prerelease
5-
# if the tag contains a hyphen.
6-
#
7-
# Publishing the release fires the "Build and Tag" workflow,
8-
# which builds dist/ and updates the version refs.
4+
# 1. Builds dist/ locally.
5+
# 2. Creates a GitHub Release with auto-generated notes,
6+
# marked as prerelease if the tag has a "-suffix".
7+
# 3. Force-pushes dist/ onto the tag.
8+
# 4. For stable releases only, also updates the rolling major/minor refs
9+
# (v2.1.3 -> v2 and v2.1).
910
on:
1011
push:
1112
tags:
@@ -27,17 +28,53 @@ jobs:
2728
release:
2829
runs-on: ubuntu-latest
2930
steps:
31+
- name: Detect prerelease
32+
id: meta
33+
run: echo "prerelease=${{ contains(github.ref_name, '-') }}" >> "$GITHUB_OUTPUT"
34+
3035
- name: Checkout
3136
uses: actions/checkout@v6
3237
with:
3338
fetch-depth: 0
3439

40+
- name: Setup Node.js
41+
uses: actions/setup-node@v6
42+
with:
43+
node-version: 24
44+
cache: npm
45+
46+
- name: Install deps and build
47+
run: npm ci && npm run build
48+
3549
- name: Create GitHub Release with auto-generated notes
3650
uses: softprops/action-gh-release@v3
3751
with:
3852
generate_release_notes: true
39-
# Mark as prerelease if the tag contains a hyphen (e.g. v2.1.3-beta.1).
40-
prerelease: ${{ contains(github.ref_name, '-') }}
53+
prerelease: ${{ steps.meta.outputs.prerelease }}
54+
55+
# Stable releases: build-and-tag-action pushes dist/ to the tag
56+
# AND updates the rolling v<major> and v<major>.<minor> refs.
57+
- name: Build and tag (stable releases)
58+
if: steps.meta.outputs.prerelease == 'false'
59+
uses: JasonEtco/build-and-tag-action@v2
60+
with:
61+
tag_name: ${{ github.ref_name }}
62+
env:
63+
GITHUB_TOKEN: ${{ github.token }}
64+
65+
# Prereleases: only push dist/ to the tag, don't touch major/minor refs.
66+
- name: Push dist/ to tag (prereleases)
67+
if: steps.meta.outputs.prerelease == 'true'
68+
env:
69+
TAG: ${{ github.ref_name }}
70+
run: |
71+
set -euo pipefail
72+
git config user.name "github-actions[bot]"
73+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
74+
git add -f dist/
75+
git commit -m "build: dist for ${TAG}"
76+
git tag -f "${TAG}"
77+
git push origin -f "refs/tags/${TAG}"
4178
4279
notify-finish:
4380
needs: [notify-start, release]

0 commit comments

Comments
 (0)