Skip to content

Commit c22ecda

Browse files
committed
refactor: manually publish production releases from release branch only
1 parent 1399fea commit c22ecda

File tree

3 files changed

+71
-8
lines changed

3 files changed

+71
-8
lines changed

.github/workflows/gh-pages.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: 'Run typedoc and publish to pages'
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
workflow_call:
5+
workflow_dispatch:
6+
77
jobs:
88
build-and-publish-docs:
99
runs-on: ubuntu-latest
@@ -15,10 +15,10 @@ jobs:
1515
- name: Checkout source code
1616
uses: actions/checkout@v4
1717

18-
- name: Use Node.js 21.x
18+
- name: Use Node.js 22.x
1919
uses: actions/setup-node@v4
2020
with:
21-
node-version: 21.x
21+
node-version: 22.x
2222

2323
- name: Npm install
2424
run: npm ci --ignore-scripts

.github/workflows/prod-release.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Prod Publish
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
prod_release:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Generate bot token
14+
uses: actions/create-github-app-token@v1
15+
id: app_token
16+
with:
17+
app-id: ${{ secrets.BOT_ID }}
18+
private-key: ${{ secrets.BOT_SK }}
19+
20+
- uses: actions/checkout@v4
21+
with:
22+
# Fetch entire repository history so we can determine version number from it
23+
fetch-depth: 0
24+
token: ${{ steps.app_token.outputs.token }}
25+
26+
- name: Set Git user as GitHub actions
27+
run: git config --global user.email "179917785+engineering-ci[bot]@users.noreply.github.com" && git config --global user.name "engineering-ci[bot]"
28+
29+
- name: Merge main -> release
30+
uses: devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f
31+
with:
32+
type: now
33+
from_branch: main
34+
target_branch: release
35+
github_token: ${{ steps.app_token.outputs.token }}
36+
37+
- name: Merge release -> main
38+
uses: devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f
39+
with:
40+
type: now
41+
from_branch: release
42+
target_branch: main
43+
message: Merge release back to main to get version increment [no ci]
44+
github_token: ${{ steps.app_token.outputs.token }}

.github/workflows/release.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ on:
77
- main
88
- release
99
workflow_dispatch:
10+
inputs:
11+
publish-prod-release:
12+
description: "Publishing a production release? If false (default), won't create a production release."
13+
type: boolean
14+
required: false
15+
default: false
1016

1117
concurrency: release
1218

@@ -15,6 +21,9 @@ permissions:
1521
issues: write
1622
pull-requests: write
1723

24+
env:
25+
PUBLISH_RELEASE: ${{ (github.ref_name != 'release' || inputs.publish-prod-release) && 'true' || 'false' }}
26+
1827
jobs:
1928
build:
2029
name: 'Build @algorandfoundation/algorand-typescript-testing'
@@ -49,7 +58,7 @@ jobs:
4958
fetch-depth: 0
5059
token: ${{ steps.app_token.outputs.token }}
5160

52-
- name: Use Node.js 20.x
61+
- name: Use Node.js 22.x
5362
uses: actions/setup-node@v4
5463
with:
5564
node-version: 22.x
@@ -67,10 +76,20 @@ jobs:
6776
GITHUB_TOKEN: ${{ steps.app_token.outputs.token }}
6877

6978
- name: Publish @algorandfoundation/algorand-typescript-testing
79+
if: ${{ env.PUBLISH_RELEASE == 'true' }}
7080
uses: JS-DevTools/npm-publish@v3
7181
with:
7282
token: ${{ secrets.NPM_TOKEN }}
7383
package: artifacts/algo-ts-testing/package.json
7484
access: 'public'
75-
# Tagging 'main' branch with latest for now, even though it's beta because we don't have a non-beta
76-
tag: ${{ github.ref_name == 'alpha' && 'alpha' || github.ref_name == 'main' && 'latest' || github.ref_name == 'release' && 'latest' || 'pre-release' }}
85+
tag: ${{ github.ref_name == 'alpha' && 'alpha' || github.ref_name == 'main' && 'beta' || github.ref_name == 'release' && 'latest' || 'pre-release' }}
86+
87+
publish-docs:
88+
name: Publish docs
89+
needs: release
90+
if: ${{ inputs.publish-prod-release }}
91+
uses: ./.github/workflows/gh-pages.yml
92+
permissions:
93+
contents: read
94+
pages: write
95+
id-token: write

0 commit comments

Comments
 (0)