diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..28e668d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +name: Release + +# Pushing a tag such as v0.1.0 builds the store package and attaches it to a +# GitHub Release, so every uploaded version stays downloadable. +on: + push: + tags: ["v*"] + +permissions: + contents: write + +jobs: + package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v7 + with: + node-version: 22 + cache: npm + + - name: Check the tag matches the manifest version + run: | + manifest=$(jq -r .version public/manifest.json) + pkg=$(jq -r .version package.json) + echo "Tag: $GITHUB_REF_NAME, manifest: $manifest, package.json: $pkg" + test "$GITHUB_REF_NAME" = "v$manifest" + test "$pkg" = "$manifest" + echo "VERSION=$manifest" >> "$GITHUB_ENV" + + - run: npm ci + - run: npm run check + - run: npm run build + - run: npm run firefox:lint + + - name: Zip the contents of dist/ + run: | + (cd dist && zip -qrX "../spectral-$VERSION.zip" .) + unzip -l "spectral-$VERSION.zip" + + - name: Create the release + env: + GH_TOKEN: ${{ github.token }} + run: | + gh release create "$GITHUB_REF_NAME" "spectral-$VERSION.zip" \ + --title "Spectral $VERSION" --generate-notes --verify-tag diff --git a/README.md b/README.md index e00cb58..6e60c02 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,7 @@ tests; see [AGENTS.md](AGENTS.md) for the architecture and conventions, and ├── dependabot.yml # npm and GitHub Actions updates └── workflows/ ├── ci.yml # check, build, Firefox lint and end-to-end tests + ├── release.yml # on a v* tag: store zip attached to a GitHub Release └── safari.yml # on demand: unsigned iOS app with the Safari extension ``` diff --git a/docs/STORE-LISTING.md b/docs/STORE-LISTING.md index 86f65a7..3083662 100644 --- a/docs/STORE-LISTING.md +++ b/docs/STORE-LISTING.md @@ -6,6 +6,23 @@ ask for nearly the same. ## Package +The version in the store is the `version` of `public/manifest.json`; it must +increase with every upload. Keep `package.json` on the same version. + +To release, bump both versions on a branch, merge it, then tag the merge +commit on `main`: + +``` +git tag v0.2.0 +git push origin v0.2.0 +``` + +The `Release` workflow checks that the tag matches both versions, runs the +checks, builds, and attaches `spectral-.zip` to a GitHub Release. +Upload that file to the store as it is. + +To build the package by hand instead: + ``` npm ci npm run build @@ -15,9 +32,6 @@ Zip the **contents** of `dist/` (the `manifest.json` at the root of the archive, not inside a folder). The result for `0.1.0` is about 21 KB and holds nine files. `store/*.zip` is ignored by git. -The version in the store is the `version` of `public/manifest.json`; it must -increase with every upload. - ## Texts **Name:** Spectral