Skip to content

Commit ee90747

Browse files
authored
Update release workflow for NPM OIDC (#28)
1 parent 67e420d commit ee90747

File tree

20 files changed

+5022
-5816
lines changed

20 files changed

+5022
-5816
lines changed

.github/actions/create-prerelease/action.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ inputs:
77
package-path:
88
description: 'package path to run action e.g. package/common'
99
required: true
10-
npm-token:
11-
description: 'token to push to npm registry'
12-
required: true
13-
10+
1411
runs:
1512
using: "composite"
1613
steps:
@@ -19,7 +16,5 @@ runs:
1916
shell: bash
2017

2118
- working-directory: ${{ inputs.package-path }}
22-
run: echo "Changes exist in ${{ inputs.package-path }}" && yarn version prerelease && yarn npm publish --access public --tag dev
23-
env:
24-
NPM_TOKEN: ${{ inputs.npm-token }}
19+
run: echo "Changes exist in ${{ inputs.package-path }}" && yarn version prerelease && yarn npm publish --access public --tag dev
2520
shell: bash

.github/actions/create-release/action.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,16 @@ inputs:
99
repo-token:
1010
description: 'token to create github release'
1111
required: true
12-
npm-token:
13-
description: 'token to push to npm registry'
14-
required: true
15-
12+
1613
runs:
1714
using: "composite"
1815
steps:
1916
- working-directory: ${{ inputs.package-path }}
20-
run: echo "Changes exist in ${{ inputs.package-path }}" && yarn npm publish --access public
21-
env:
22-
NPM_TOKEN: ${{ inputs.npm-token }}
17+
run: echo "Changes exist in ${{ inputs.package-path }}" && yarn npm publish --access public
2318
shell: bash
2419

2520
- working-directory: ${{ github.workspace }}
2621
run: node ${{ github.action_path }}/gh-release-script.js ${{ github.workspace }}/${{ inputs.package-path }} ${{ github.sha }}
27-
env:
22+
env:
2823
REPO_TOKEN: ${{ inputs.repo-token }}
2924
shell: bash

.github/workflows/benchmark.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565

6666
steps:
6767
#Check out
68-
- uses: actions/checkout@v4
68+
- uses: actions/checkout@v5
6969
with:
7070
fetch-depth: 100
7171
token: ${{ secrets.REPO_TOKEN }}
@@ -82,12 +82,12 @@ jobs:
8282
echo "::set-output name=network-endpoint::${NETWORK_ENDPOINT}"
8383
echo "::add-mask::${NETWORK_ENDPOINT}"
8484
# Store the prepared NETWORK_ENDPOINT in an environment variable
85-
echo "NETWORK_ENDPOINT=${NETWORK_ENDPOINT}" >> $GITHUB_ENV
85+
echo "NETWORK_ENDPOINT=${NETWORK_ENDPOINT}" >> $GITHUB_ENV
8686
8787
- name: Install Docker inside the container
8888
run: |
8989
apt-get update
90-
apt-get install -y docker.io
90+
apt-get install -y docker.io
9191
9292
- name: Install PostgreSQL client
9393
run: |
@@ -201,4 +201,3 @@ jobs:
201201
}
202202
env:
203203
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
204-

.github/workflows/discord.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111

1212
steps:
1313
- name: Send release details to Discord
14-
uses: rjstone/discord-webhook-notify@v1
14+
uses: rjstone/discord-webhook-notify@v2
1515
with:
1616
webhookUrl: ${{ secrets.DISCORD_RELEASE_NOTES_WEBHOOK }}
1717
color: '#6499ff'

.github/workflows/gh-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
#Check out
11-
- uses: actions/checkout@v4
11+
- uses: actions/checkout@v5
1212
with:
1313
fetch-depth: 100
1414

1515
- name: Setup Node.js environment
16-
uses: actions/setup-node@v4
16+
uses: actions/setup-node@v5
1717
with:
1818
node-version: lts/*
1919

.github/workflows/node-docker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
outputs:
1717
changes_found: ${{ steps.check_changes.outputs.changes_found }}
1818
steps:
19-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v5
2020
with:
2121
fetch-depth: 2
2222
- name: Check for package changes and commit message
@@ -39,7 +39,7 @@ jobs:
3939
if: needs.check.outputs.changes_found == 'true'
4040
runs-on: ubuntu-latest
4141
steps:
42-
- uses: actions/checkout@v4
42+
- uses: actions/checkout@v5
4343
with:
4444
fetch-depth: 100
4545
token: ${{ secrets.REPO_TOKEN }}

.github/workflows/pr.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
SUBQL_ACCESS_TOKEN_TEST: ${{ secrets.SUBQL_ACCESS_TOKEN_TEST }}
1313
SUBQL_ORG_TEST: ${{ secrets.SUBQL_ORG_TEST }}
1414
steps:
15-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@v5
1616
- name: Setup Node.js environment
17-
uses: actions/setup-node@v4
17+
uses: actions/setup-node@v5
1818
with:
1919
node-version: lts/*
2020
- run: yarn
@@ -46,10 +46,10 @@ jobs:
4646
DB_PORT: 5432
4747
HTTP_ENDPOINT: ${{ secrets.HTTP_ENDPOINT }}
4848
steps:
49-
- uses: actions/checkout@v4
49+
- uses: actions/checkout@v5
5050

5151
- name: Setup Node.js environment
52-
uses: actions/setup-node@v4
52+
uses: actions/setup-node@v5
5353
with:
5454
node-version: lts/*
5555

.github/workflows/prerelease.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
name: "Publish"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- ".github/workflows/**"
8+
9+
permissions:
10+
id-token: write # Required for OIDC
11+
contents: read
12+
13+
concurrency:
14+
group: publish
15+
cancel-in-progress: false
16+
17+
jobs:
18+
19+
pre-ci:
20+
name: Pre-CI (Extract Commit Message)
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 1
23+
outputs:
24+
commit-message: ${{ steps.get_commit_message.outputs.commit-message }}
25+
steps:
26+
- uses: actions/checkout@v5
27+
with:
28+
fetch-depth: 0
29+
30+
- id: get_commit_message
31+
run: |
32+
COMMIT_MSG_TEMP="${{ github.event.head_commit.message }}"
33+
if [ -n "$COMMIT_MSG_TEMP" ]
34+
then
35+
commit_msg="$COMMIT_MSG_TEMP"
36+
echo "commit-message=${commit_msg}" | head -n 1 >> "$GITHUB_OUTPUT"
37+
else
38+
commit_message=$(git log -1 --pretty=%B | head -n 1)
39+
echo "commit-message=$commit_message" >> "$GITHUB_OUTPUT"
40+
fi
41+
42+
- name: Debug commit message
43+
run: |
44+
echo "Commit message: ${{ steps.get_commit_message.outputs.commit-message }}"
45+
46+
setup:
47+
name: Setup & Detect Changes
48+
needs: pre-ci
49+
runs-on: ubuntu-latest
50+
outputs:
51+
changed-types: ${{ steps.changed-types.outputs.changed }}
52+
changed-common-solana: ${{ steps.changed-common-solana.outputs.changed }}
53+
changed-node: ${{ steps.changed-node.outputs.changed }}
54+
steps:
55+
- uses: actions/checkout@v5
56+
with:
57+
fetch-depth: 100 # Needed to detect changes by having commit history
58+
59+
- uses: marceloprado/has-changed-path@v1
60+
id: changed-types
61+
with:
62+
paths: packages/types
63+
64+
- uses: marceloprado/has-changed-path@v1
65+
id: changed-common-solana
66+
with:
67+
paths: packages/common-solana
68+
69+
- uses: marceloprado/has-changed-path@v1
70+
id: changed-node
71+
with:
72+
paths: packages/node
73+
74+
release:
75+
name: Release Publish
76+
needs: [pre-ci, setup]
77+
if: >
78+
!startsWith(github.event.head_commit.message, '[SKIP CI]')
79+
&& startsWith(github.event.head_commit.message, '[release]')
80+
&& github.repository == 'subquery/subql-solana'
81+
runs-on: ubuntu-latest
82+
steps:
83+
- uses: actions/checkout@v5
84+
with:
85+
fetch-depth: 0
86+
87+
- name: Setup Node.js environment
88+
uses: actions/setup-node@v5
89+
with:
90+
node-version: lts/*
91+
92+
- name: Update npm
93+
run: npm install -g npm@latest
94+
95+
- run: yarn
96+
97+
- name: build
98+
run: yarn build
99+
100+
# Publish to npm and github releases
101+
- name: Publish Types
102+
if: needs.setup.outputs.changed-types == 'true'
103+
uses: ./.github/actions/create-release
104+
with:
105+
package-path: packages/types
106+
repo-token: ${{ secrets.REPO_TOKEN }}
107+
108+
- name: Publish Common Solana
109+
if: needs.setup.outputs.changed-common-solana == 'true'
110+
uses: ./.github/actions/create-release
111+
with:
112+
package-path: packages/common-solana
113+
repo-token: ${{ secrets.REPO_TOKEN }}
114+
115+
- name: Publish Node
116+
if: needs.setup.outputs.changed-node == 'true'
117+
uses: ./.github/actions/create-release
118+
with:
119+
package-path: packages/node
120+
repo-token: ${{ secrets.REPO_TOKEN }}
121+
122+
prerelease:
123+
name: Prerelease Publish
124+
needs: [pre-ci, setup]
125+
if: >
126+
!startsWith(needs.pre-ci.outputs.commit-message, '[SKIP CI]')
127+
&& !startsWith(needs.pre-ci.outputs.commit-message, '[release]')
128+
&& github.repository == 'subquery/subql-solana'
129+
runs-on: ubuntu-latest
130+
steps:
131+
- uses: actions/checkout@v5
132+
with:
133+
fetch-depth: 0
134+
token: ${{ secrets.REPO_TOKEN }} # Needed to push changes back to repo
135+
136+
- name: Setup Node.js environment
137+
uses: actions/setup-node@v5
138+
with:
139+
node-version: lts/*
140+
141+
- name: Update npm
142+
run: npm install -g npm@latest
143+
144+
- run: yarn
145+
146+
- name: build
147+
run: yarn build
148+
149+
# Prerelease publish steps
150+
- name: Bump types & deploy
151+
if: needs.setup.outputs.changed-types == 'true'
152+
uses: ./.github/actions/create-prerelease
153+
with:
154+
package-path: packages/types
155+
156+
- name: Bump common Solana & deploy
157+
if: needs.setup.outputs.changed-common-solana == 'true'
158+
uses: ./.github/actions/create-prerelease
159+
with:
160+
package-path: packages/common-solana
161+
162+
- name: Bump node & deploy
163+
if: needs.setup.outputs.changed-node == 'true'
164+
uses: ./.github/actions/create-prerelease
165+
with:
166+
package-path: packages/node
167+
168+
169+
- name: Commit changes
170+
uses: EndBug/add-and-commit@v9
171+
with:
172+
message: "[SKIP CI] Prerelease"
173+
default_author: github_actions

0 commit comments

Comments
 (0)