Skip to content

Commit e631314

Browse files
committed
feat: release workflows
1 parent 047a98f commit e631314

4 files changed

Lines changed: 158 additions & 0 deletions

File tree

.github/workflows/release-npm.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Reusable Release NPM Package Workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
build:
7+
required: false
8+
type: string
9+
default: ""
10+
cr:
11+
description: Enable Continuous Releases, powered by pkg-pr-new
12+
required: false
13+
type: boolean
14+
default: false
15+
16+
jobs:
17+
release:
18+
name: Release
19+
runs-on: ubuntu-latest
20+
21+
permissions:
22+
contents: write
23+
id-token: write
24+
25+
steps:
26+
- name: Setup JS
27+
uses: zotero-plugin-dev/workflows/setup-js@main
28+
with:
29+
fetch-all: true
30+
31+
- name: Build
32+
if: ${{ inputs.build }}
33+
run: ${{ inputs.build }}
34+
35+
# ========================================
36+
# Production release (Tag-triggered)
37+
# Runs only when pushing a version tag
38+
# ========================================
39+
- name: Publish to NPM and sync Changelog
40+
if: github.event_name == 'push' && github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/')
41+
run: |
42+
pnpm publish --no-git-checks --access public
43+
pnpx changelogithub
44+
env:
45+
NPM_CONFIG_PROVENANCE: true
46+
47+
# ========================================
48+
# Preview release (Push / PR-triggered)
49+
# ========================================
50+
- name: Publish Preview Package (pkg-pr-new)
51+
if: ${{ inputs.cr == true && github.ref_type != 'tag' }}
52+
run: pnpx pkg-pr-new publish --compact --no-template --pnpm
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Reusable Release Zotero Plugin Workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
fetch-all:
7+
description: "Whether to fetch all commits and submodules."
8+
type: boolean
9+
required: false
10+
default: false
11+
build:
12+
description: "The command to build the project. Set to an empty string to skip."
13+
type: string
14+
required: false
15+
default: ""
16+
release:
17+
description: "The command to execute the release (e.g., publishing to GitHub Releases)."
18+
type: string
19+
required: true
20+
default: "pnpm release"
21+
comment-template:
22+
description: "Template for the comment posted on related Issues/PRs after release."
23+
type: string
24+
required: false
25+
default: |
26+
:rocket: _This ticket has been resolved in {release_tag}. See {release_link} for release notes._
27+
28+
secrets:
29+
GITHUB_TOKEN:
30+
description: "A GITHUB_TOKEN with write permissions for contents, issues, and pull-requests."
31+
required: false
32+
33+
permissions:
34+
contents: write
35+
issues: write
36+
pull-requests: write
37+
38+
jobs:
39+
release:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Setup JS
43+
uses: zotero-plugin-dev/workflows/setup-js@main
44+
with:
45+
fetch-all: ${{ inputs.fetch-all }}
46+
47+
- name: Build
48+
if: inputs.build != ''
49+
run: ${{ inputs.build }}
50+
51+
- name: Release to GitHub
52+
run: ${{ inputs.release }}
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- run: sleep 1s
57+
58+
- name: Notify release
59+
uses: apexskier/github-release-commenter@v1
60+
continue-on-error: true
61+
with:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
comment-template: ${{ inputs.comment-template }}

examples/release-npm.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- v**
9+
pull_request:
10+
branches:
11+
- main
12+
13+
jobs:
14+
release:
15+
uses: zotero-plugin-dev/workflows/.github/workflows/release-npm.yml@main
16+
with:
17+
build: "pnpm build"
18+
cr: true
19+
permissions:
20+
contents: write
21+
id-token: write

examples/release-plugin.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v**
7+
8+
permissions:
9+
contents: write
10+
issues: write
11+
pull-requests: write
12+
13+
jobs:
14+
create-release:
15+
uses: zotero-plugin-dev/workflows/.github/workflows/release-plugin.yml@main
16+
17+
# You can customize any of the inputs here.
18+
# If you omit an input, its default value will be used.
19+
# with:
20+
# build: ""
21+
# release: "pnpm release"
22+
# secrets: inherit

0 commit comments

Comments
 (0)