Skip to content

Merge pull request #29 from kosli-dev/20260623_fix_tags #12

Merge pull request #29 from kosli-dev/20260623_fix_tags

Merge pull request #29 from kosli-dev/20260623_fix_tags #12

Workflow file for this run

name: Release
# Triggered by pushing a semver tag (e.g. v2.1.3, v2.1.3-beta.1).
# 1. Builds dist/ locally.
# 2. Creates a GitHub Release with auto-generated notes,
# marked as prerelease if the tag has a "-suffix".
# 3. Force-pushes dist/ onto the tag.
# 4. For stable releases only, also updates the rolling major/minor refs
# (v2.1.3 -> v2 and v2.1).
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: false
jobs:
notify-start:
runs-on: ubuntu-latest
steps:
- uses: kosli-dev/reusable-actions/slack-release-notify@main
with:
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
slack-channel-id: ${{ vars.SLACK_CHANNEL_ID }}
stage: start
release:
runs-on: ubuntu-latest
steps:
- name: Detect prerelease
id: meta
run: echo "prerelease=${{ contains(github.ref_name, '-') }}" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ github.sha }} # immutable; build-and-tag moves the tag later
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- name: Install deps and build
run: npm ci && npm run build
# Stable releases: build-and-tag-action pushes dist/ to the tag
# AND updates the rolling v<major> and v<major>.<minor> refs.
- name: Build and tag (stable releases)
if: steps.meta.outputs.prerelease == 'false'
uses: JasonEtco/build-and-tag-action@v2
with:
tag_name: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ github.token }}
# Prereleases: only push dist/ to the tag, don't touch major/minor refs.
- name: Push dist/ to tag (prereleases)
if: steps.meta.outputs.prerelease == 'true'
env:
TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -f dist/
git commit -m "build: dist for ${TAG}"
git tag -f "${TAG}"
git push origin -f "refs/tags/${TAG}"
- name: Create GitHub Release with auto-generated notes
uses: softprops/action-gh-release@v3
with:
generate_release_notes: true
prerelease: ${{ steps.meta.outputs.prerelease }}
notify-finish:
needs: [notify-start, release]
if: always() && needs.notify-start.result == 'success'
runs-on: ubuntu-latest
permissions:
actions: read # ← needed to fetch run_started_at for duration
contents: read # ← needed to read release notes via `gh release view`
steps:
- name: Determine status
id: status
run: |
if [[ "${{ !contains(join(needs.*.result, ','), 'failure') && !contains(join(needs.*.result, ','), 'cancelled') }}" == "true" ]]; then
echo "value=success" >> "$GITHUB_OUTPUT"
else
echo "value=failure" >> "$GITHUB_OUTPUT"
fi
- uses: kosli-dev/reusable-actions/slack-release-notify@main
with:
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
slack-channel-id: ${{ vars.SLACK_CHANNEL_ID }}
stage: finish
status: ${{ steps.status.outputs.value }}