Skip to content

Commit c8d7271

Browse files
committed
chore: update publish workflow for trusted publishing
1 parent 6aae151 commit c8d7271

3 files changed

Lines changed: 153 additions & 128 deletions

File tree

.github/dependabot.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "github-actions"
4-
directory: "/"
3+
- package-ecosystem: 'github-actions'
4+
directory: '/'
55
schedule:
6-
interval: "weekly"
6+
interval: 'weekly'
77
reviewers:
8-
- "@nrkno/sofie-ops"
8+
- '@Sofie-Automation/operations'

.github/workflows/node.yaml

Lines changed: 22 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ name: Node CI
22

33
on:
44
push:
5-
branches:
6-
- '**'
7-
tags:
8-
- '[0-9]+.[0-9]+.[0-9]+*'
9-
- 'v[0-9]+.[0-9]+.[0-9]+*'
105
pull_request:
116

127
jobs:
@@ -17,15 +12,17 @@ jobs:
1712
timeout-minutes: 15
1813

1914
steps:
20-
- uses: actions/checkout@v5
15+
- name: Git checkout
16+
uses: actions/checkout@v5
2117
with:
2218
persist-credentials: false
23-
- name: Use Node.js 14.x
19+
- name: Use Node.js 18.x
2420
uses: actions/setup-node@v6
2521
with:
26-
node-version: 14.x
22+
node-version: 18.x
2723
- name: Prepare Environment
2824
run: |
25+
corepack enable
2926
yarn install
3027
yarn build
3128
env:
@@ -44,10 +41,11 @@ jobs:
4441
strategy:
4542
fail-fast: false
4643
matrix:
47-
node-version: [14.x, 16.x, 18.x, 20.x]
44+
node-version: [14.x, 16.x, 18.x, 20.x, 22.x, 24.x]
4845

4946
steps:
50-
- uses: actions/checkout@v5
47+
- name: Git checkout
48+
uses: actions/checkout@v5
5149
with:
5250
persist-credentials: false
5351
- name: Use Node.js ${{ matrix.node-version }}
@@ -56,6 +54,7 @@ jobs:
5654
node-version: ${{ matrix.node-version }}
5755
- name: Prepare Environment
5856
run: |
57+
corepack enable
5958
yarn install
6059
env:
6160
CI: true
@@ -68,104 +67,32 @@ jobs:
6867
uses: codecov/codecov-action@v5
6968
env:
7069
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
71-
if: matrix.node-version == '14.x'
70+
if: matrix.node-version == '18.x'
7271
- name: Check docs generation
73-
if: matrix.node-version == '14.x'
72+
if: matrix.node-version == '18.x'
7473
run: |
7574
yarn docs:test
7675
env:
7776
CI: true
7877

79-
release:
80-
name: Release
81-
runs-on: ubuntu-latest
82-
timeout-minutes: 15
83-
84-
# only run for tags
85-
if: contains(github.ref, 'refs/tags/')
86-
87-
needs:
88-
- test
89-
- validate-dependencies
90-
91-
steps:
92-
- uses: actions/checkout@v5
93-
with:
94-
fetch-depth: 0
95-
persist-credentials: false
96-
- name: Use Node.js 14.x
97-
uses: actions/setup-node@v6
98-
with:
99-
node-version: 14.x
100-
- name: Check release is desired
101-
id: do-publish
102-
run: |
103-
if [ -z "${{ secrets.NPM_TOKEN }}" ]; then
104-
echo "No Token"
105-
else
106-
107-
PACKAGE_NAME=$(yarn info -s . name)
108-
PUBLISHED_VERSION=$(yarn info -s $PACKAGE_NAME version)
109-
THIS_VERSION=$(node -p "require('./package.json').version")
110-
# Simple bash helper to comapre version numbers
111-
verlte() {
112-
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
113-
}
114-
verlt() {
115-
[ "$1" = "$2" ] && return 1 || verlte $1 $2
116-
}
117-
if verlt $PUBLISHED_VERSION $THIS_VERSION
118-
then
119-
echo "Publishing latest"
120-
echo "tag=latest" >> $GITHUB_OUTPUT
121-
else
122-
echo "Publishing hotfix"
123-
echo "tag=hotfix" >> $GITHUB_OUTPUT
124-
fi
125-
126-
fi
127-
- name: Prepare build
128-
if: ${{ steps.do-publish.outputs.tag }}
129-
run: |
130-
yarn install
131-
yarn build
132-
env:
133-
CI: true
134-
- name: Publish to NPM
135-
if: ${{ steps.do-publish.outputs.tag }}
136-
run: |
137-
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
138-
NEW_VERSION=$(node -p "require('./package.json').version")
139-
yarn publish --access=public --new-version=$NEW_VERSION --network-timeout 100000 --tag ${{ steps.do-publish.outputs.tag }}
140-
echo "**Published:** $NEW_VERSION" >> $GITHUB_STEP_SUMMARY
141-
env:
142-
CI: true
143-
- name: Generate docs
144-
if: ${{ steps.do-publish.outputs.tag }} == 'latest'
145-
run: |
146-
yarn docs:html
147-
- name: Publish docs
148-
uses: peaceiris/actions-gh-pages@v4
149-
with:
150-
github_token: ${{ secrets.GITHUB_TOKEN }}
151-
publish_dir: ./docs
152-
15378
validate-dependencies:
15479
name: Validate production dependencies
15580
runs-on: ubuntu-latest
15681
continue-on-error: true
15782
timeout-minutes: 15
15883

15984
steps:
160-
- uses: actions/checkout@v5
85+
- name: Git checkout
86+
uses: actions/checkout@v5
16187
with:
16288
persist-credentials: false
163-
- name: Use Node.js 14.x
89+
- name: Use Node.js 18.x
16490
uses: actions/setup-node@v6
16591
with:
166-
node-version: 14.x
92+
node-version: 18.x
16793
- name: Prepare Environment
16894
run: |
95+
corepack enable
16996
yarn install
17097
env:
17198
CI: true
@@ -186,15 +113,17 @@ jobs:
186113
timeout-minutes: 15
187114

188115
steps:
189-
- uses: actions/checkout@v5
116+
- name: Git checkout
117+
uses: actions/checkout@v5
190118
with:
191119
persist-credentials: false
192-
- name: Use Node.js 14.x
120+
- name: Use Node.js 18.x
193121
uses: actions/setup-node@v6
194122
with:
195-
node-version: 14.x
123+
node-version: 18.x
196124
- name: Prepare Environment
197125
run: |
126+
corepack enable
198127
yarn install
199128
env:
200129
CI: true
@@ -207,4 +136,4 @@ jobs:
207136
run: |
208137
yarn validate:dev-dependencies
209138
env:
210-
CI: true
139+
CI: true

0 commit comments

Comments
 (0)