Skip to content

Commit fc3e2bf

Browse files
committed
adding workflows for onboarding to the npm-release-workflows shared release
1 parent 37423ff commit fc3e2bf

File tree

3 files changed

+212
-0
lines changed

3 files changed

+212
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Release on Push
2+
3+
# This workflow automatically creates GitHub releases after release PRs are merged
4+
# It triggers on push to branches defined in your release-channels.yml
5+
# This workflow is for PUBLIC repositories that need to use workflows from a PRIVATE repository
6+
# It uses token-based checkout to access the private npm-release-workflows repository
7+
#
8+
# SETUP INSTRUCTIONS:
9+
# 1. Ensure WORKFLOWS_ACCESS_GITHUB_TOKEN secret is configured (see docs/credentials.md)
10+
# 2. Replace 'heroku' with your GitHub organization name
11+
# 3. Replace 'npm-release-workflows' with the actual repository name if different
12+
# 4. Update the branches list to match your release-channels.yml branch names
13+
# 5. Copy this file to .github/workflows/release-on-push.yml in your project
14+
#
15+
# IMPORTANT: The branches in the push trigger MUST match the branch names
16+
# defined in your release-channels.yml file
17+
18+
on:
19+
push:
20+
branches:
21+
# Add all branches that are defined in your release-channels.yml
22+
# Common examples:
23+
- main # Stable releases
24+
- beta # Beta/prerelease channel
25+
# - alpha # Uncomment if you have an alpha channel
26+
# Add any other branches defined in your release-channels.yml
27+
28+
jobs:
29+
create-release:
30+
runs-on: ubuntu-latest
31+
permissions:
32+
contents: write
33+
pull-requests: write
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- name: Checkout workflows repository
38+
uses: actions/checkout@v4
39+
with:
40+
repository: heroku/npm-release-workflows
41+
token: ${{ secrets.WORKFLOWS_ACCESS_GITHUB_TOKEN }}
42+
path: workflows-repo
43+
ref: main
44+
45+
- name: Create GitHub Release
46+
uses: ./workflows-repo/.github/actions/release-on-push-create-release-public
47+
with:
48+
# Update package-manager to match your project (npm, yarn, or pnpm)
49+
# Used for installing dependencies when creating releases
50+
package-manager: pnpm
51+
branch_name: ${{ github.ref_name }}
52+
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Release
2+
3+
# This workflow is for PUBLIC repositories that need to use workflows from a PRIVATE repository
4+
# It uses token-based checkout to access the private npm-release-workflows repository
5+
#
6+
# SETUP INSTRUCTIONS:
7+
# 1. Create a Personal Access Token (PAT) or GitHub App token with 'repo' scope
8+
# - See documentation for token creation instructions (docs/credentials.md)
9+
# 2. Add the token as a secret named 'WORKFLOWS_ACCESS_GITHUB_TOKEN' in your repository
10+
# 3. Replace 'heroku' with your GitHub organization name
11+
# 4. Replace 'npm-release-workflows' with the actual repository name if different
12+
# 5. Adjust the hardcoded values in the workflow (package_manager, test_command, lint_command, build_command)
13+
# based on your project's needs - these are hardcoded in the workflow, not passed as inputs
14+
# 6. Copy this file to .github/workflows/release.yml in your project
15+
16+
on:
17+
workflow_dispatch:
18+
inputs:
19+
# DRY RUN MODE
20+
# Set to true to test the release process without actually publishing to npm
21+
# Useful for validating workflow changes or testing version bumps
22+
dry_run:
23+
description: 'Test release without publishing (creates PR but skips npm publish)'
24+
type: boolean
25+
default: false
26+
required: false
27+
28+
jobs:
29+
validate:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Checkout workflows repository
35+
uses: actions/checkout@v4
36+
with:
37+
repository: heroku/npm-release-workflows
38+
token: ${{ secrets.WORKFLOWS_ACCESS_GITHUB_TOKEN }}
39+
path: workflows-repo
40+
ref: main
41+
42+
- name: Validate and test
43+
uses: ./workflows-repo/.github/actions/release-validate-public
44+
with:
45+
# Update these values to match your project:
46+
package-manager: pnpm # Options: npm, yarn, or pnpm (must match your project's package manager)
47+
lint_command: 'run lint' # Set to '' to skip if no lint script exists
48+
test_command: 'test' # Set to '' to skip if no test script exists
49+
50+
release-please-pr:
51+
needs: validate
52+
runs-on: ubuntu-latest
53+
permissions:
54+
contents: write
55+
pull-requests: write
56+
outputs:
57+
release_created: ${{ steps.release-workflow.outputs.release_created }}
58+
tag_name: ${{ steps.release-workflow.outputs.tag_name }}
59+
pr_number: ${{ steps.release-workflow.outputs.pr_number }}
60+
config_file: ${{ steps.release-workflow.outputs.config_file }}
61+
manifest_file: ${{ steps.release-workflow.outputs.manifest_file }}
62+
npm_tag: ${{ steps.release-workflow.outputs.npm_tag }}
63+
package_name: ${{ steps.release-workflow.outputs.package_name }}
64+
no_release_needed: ${{ steps.release-workflow.outputs.no_release_needed }}
65+
pr_already_exists: ${{ steps.release-workflow.outputs.pr_already_exists }}
66+
steps:
67+
- uses: actions/checkout@v4
68+
69+
- name: Checkout workflows repository
70+
uses: actions/checkout@v4
71+
with:
72+
repository: heroku/npm-release-workflows
73+
token: ${{ secrets.WORKFLOWS_ACCESS_GITHUB_TOKEN }}
74+
path: workflows-repo
75+
ref: main
76+
77+
- name: Create release PR
78+
id: release-workflow
79+
uses: ./workflows-repo/.github/actions/release-please-pr-public
80+
with:
81+
# Update package-manager to match your project (npm, yarn, or pnpm)
82+
package-manager: pnpm # Must match your project's package manager
83+
branch_name: ${{ github.ref_name }}
84+
dry_run: ${{ inputs.dry_run }}
85+
86+
publish:
87+
needs: release-please-pr
88+
if: needs.release-please-pr.result == 'success' && (needs.release-please-pr.outputs.pr_number != '' || needs.release-please-pr.outputs.pr_already_exists == 'true')
89+
runs-on: ubuntu-latest
90+
permissions:
91+
contents: write
92+
pull-requests: write
93+
id-token: write
94+
steps:
95+
- uses: actions/checkout@v4
96+
97+
- name: Checkout workflows repository
98+
uses: actions/checkout@v4
99+
with:
100+
repository: heroku/npm-release-workflows
101+
token: ${{ secrets.WORKFLOWS_ACCESS_GITHUB_TOKEN }}
102+
path: workflows-repo
103+
ref: main
104+
105+
- name: Publish to npm
106+
uses: ./workflows-repo/.github/actions/release-publish-public
107+
with:
108+
# Update these values to match your project:
109+
package-manager: pnpm # Options: npm, yarn, or pnpm (used for installing dependencies and building; publishing always uses pnpm)
110+
workflows_token: ${{ secrets.WORKFLOWS_ACCESS_GITHUB_TOKEN }}
111+
build_command: 'run build' # Set to '' to skip if no build script exists
112+
dry_run: ${{ inputs.dry_run }}
113+
npm_tag: ${{ needs.release-please-pr.outputs.npm_tag }}
114+
package_name: ${{ needs.release-please-pr.outputs.package_name }}
115+
pr_number: ${{ needs.release-please-pr.outputs.pr_number }}
116+
branch_name: ${{ github.ref_name }}
117+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Update Release Configs
2+
3+
# This workflow generates release-please config files from your release-channels.yml
4+
# Run this whenever you modify release-channels.yml to regenerate the config files
5+
# This workflow is for PUBLIC repositories that need to use workflows from a PRIVATE repository
6+
# It uses token-based checkout to access the private npm-release-workflows repository
7+
#
8+
# SETUP INSTRUCTIONS:
9+
# 1. Ensure WORKFLOWS_ACCESS_GITHUB_TOKEN secret is configured (see docs/credentials.md)
10+
# 2. Replace 'heroku' with your GitHub organization name
11+
# 3. Replace 'npm-release-workflows' with the actual repository name if different
12+
# 4. Copy this file to .github/workflows/update-release-configs.yml in your project
13+
#
14+
# USAGE:
15+
# - Edit release-channels.yml in your project
16+
# - Go to Actions → "Update Release Configs" → "Run workflow"
17+
# - A PR will be created if the generated configs differ from committed versions
18+
# - Review and merge the PR to commit both release-channels.yml and generated configs
19+
20+
on:
21+
workflow_dispatch:
22+
# No inputs needed - this workflow reads from release-channels.yml
23+
24+
jobs:
25+
update-configs:
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: write
29+
pull-requests: write
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Checkout workflows repository
34+
uses: actions/checkout@v4
35+
with:
36+
repository: heroku/npm-release-workflows
37+
token: ${{ secrets.WORKFLOWS_ACCESS_GITHUB_TOKEN }}
38+
path: workflows-repo
39+
ref: main
40+
41+
- name: Update release configs
42+
uses: ./workflows-repo/.github/actions/update-release-configs-job-public
43+

0 commit comments

Comments
 (0)