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
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release

on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-*"

permissions:
contents: write

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

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Build plugin
run: npm run build

- name: Verify manifest version matches tag
run: |
tag="${GITHUB_REF#refs/tags/}"
manifest_version=$(node -p "require('./manifest.json').version")
if [ "$tag" != "$manifest_version" ]; then
echo "::error::Tag '$tag' does not match manifest.json version '$manifest_version'."
echo "Run 'npm version $tag' locally to bump all files in sync, then push the tag."
exit 1
fi

- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
tag="${GITHUB_REF#refs/tags/}"
if [[ "$tag" == *-* ]]; then
prerelease_flag="--prerelease"
else
prerelease_flag=""
fi
gh release create "$tag" \
--title "$tag" \
--notes "Release $tag" \
$prerelease_flag \
main.js manifest.json styles.css
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tag-version-prefix=
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"lint": "svelte-check --tsconfig tsconfig.json --fail-on-hints && eslint . --ext .ts",
"test:unit": "vitest",
"dev": "rollup --config rollup.config.js -w",
"build": "npm run lint && rollup --config rollup.config.js --environment BUILD:production"
"build": "npm run lint && rollup --config rollup.config.js --environment BUILD:production",
"version": "node version-bump.mjs && git add manifest.json versions.json"
},
"keywords": [],
"author": "",
Expand Down
21 changes: 21 additions & 0 deletions version-bump.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { readFileSync, writeFileSync } from "fs";

const targetVersion = process.env.npm_package_version;
if (!targetVersion) {
throw new Error(
"npm_package_version is not set; run this via `npm version <x.y.z[-pre]>`."
);
}

const manifest = JSON.parse(readFileSync("manifest.json", "utf8"));
const { minAppVersion } = manifest;
manifest.version = targetVersion;
writeFileSync("manifest.json", JSON.stringify(manifest, null, 2) + "\n");

const versions = JSON.parse(readFileSync("versions.json", "utf8"));
versions[targetVersion] = minAppVersion;
writeFileSync("versions.json", JSON.stringify(versions, null, 2) + "\n");

console.log(
`Synced manifest.json and versions.json to ${targetVersion} (minAppVersion ${minAppVersion}).`
);
Loading