Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Release to npm

on:
workflow_dispatch:
inputs:
bump:
description: 'Version bump'
type: choice
options:
- patch
- minor
- major
default: patch

concurrency:
group: release
cancel-in-progress: false

jobs:
release:
if: github.ref_name == 'staging'
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Verify staging branch
run: |
if [ "${{ github.ref_name }}" != "staging" ]; then
echo "::error::Releases can only be triggered from the 'staging' branch (got: ${{ github.ref_name }})"
exit 1
fi

- uses: actions/checkout@v4
with:
ref: staging
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'

- run: npm ci

- name: Configure git identity
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Bump version, rebuild /dist, commit and tag
run: |
NEW_VERSION=$(npm version ${{ inputs.bump }} --no-git-tag-version)
NEW_VERSION="${NEW_VERSION#v}"
npm run build
git add package.json package-lock.json dist/
git commit -m "Packaging ${NEW_VERSION} with rebuilt /dist"
git tag "v${NEW_VERSION}"

- name: Push to GitHub
run: git push origin staging --follow-tags

- name: Publish to npm with provenance
run: npm publish --provenance --access public
25 changes: 25 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Validate build

on:
push:
branches-ignore:
- staging

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'

- run: npm ci

- name: Build /dist
run: npm run build

- name: Validate npm package (dry-run)
run: npm publish --dry-run
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ Miscellaneous notes:

## Versioning and publishing to npm

> Releases can be automated via [Actions → "Release to npm"](https://github.com/OpenHistoricalMap/map-styles/actions/workflows/release.yml) — click **Run workflow**, choose `patch` / `minor` / `major`, and it builds `/dist`, commits, tags, and publishes with provenance via npm Trusted Publishers (no token required). Manual steps below remain as a fallback.

1. increment the version in `package.json`, e.g., `0.9.7`
1. commit your style changes, including `/dist/*` & `package.json`, push to GitHub, and [create a corresponding release](https://github.com/OpenHistoricalMap/map-styles/releases/new), e.g., `v0.9.7`
1. publish to npm using `npm publish`
Expand Down
Loading