1
- name : Release publish NPM
1
+ name : Release publish NPM / container image
2
2
on :
3
3
push :
4
4
branches :
5
5
- release
6
6
7
7
jobs :
8
- release-publish-npm :
8
+ final-check-before-release :
9
9
runs-on : ubuntu-latest
10
+ outputs :
11
+ latest-release-name : ${{ steps.release-info.outputs.latest-release-name }}
12
+ is-pre-release : ${{ steps.release-info.outputs.is-pre-release }}
13
+ container-release-tag : ${{ steps.release-info.outputs.container-release-tag }}
10
14
steps :
11
15
- name : Checkout code
12
16
uses : actions/checkout@v4
13
17
14
18
- name : Setup Node.js
15
19
uses : actions/setup-node@v4
16
20
with :
17
- node-version : 18
21
+ node-version : 20
18
22
registry-url : https://registry.npmjs.org/
19
23
20
24
- name : Install dependencies
@@ -26,18 +30,17 @@ jobs:
26
30
- name : Run integration tests
27
31
run : npm run if-check -- -d manifests/outputs
28
32
29
- - name : Initialize git user email
30
- run : git config --global user.email "${{ env.RELEASE_USER_EMAIL }}"
31
-
32
- - name : Initialize git user name
33
- run : git config --global user.name "Release publish workflow"
33
+ - name : Archive checked source tree (to keep permissions)
34
+ run : tar cfz /tmp/src.tar.gz .
34
35
35
- - name : Initialize npm config
36
- run : npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
37
- env :
38
- NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
36
+ - name : Upload checked source tree for the release
37
+ uses : actions/upload-artifact@v4
38
+ with :
39
+ name : src
40
+ path : /tmp/src.tar.gz
39
41
40
42
- name : Fetch latest release info
43
+ id : release-info
41
44
run : |
42
45
RELEASE_JSON=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
43
46
"https://api.github.com/repos/${{ github.repository }}/releases")
@@ -50,24 +53,85 @@ jobs:
50
53
LATEST_RELEASE_NAME=$(echo "$RELEASE_JSON" | jq -r '.[0].name')
51
54
IS_PRE_RELEASE=$(echo "$RELEASE_JSON" | jq -r '.[0].prerelease')
52
55
53
- echo "LATEST_RELEASE_NAME=$LATEST_RELEASE_NAME" >> $GITHUB_ENV
54
- echo "IS_PRE_RELEASE=$IS_PRE_RELEASE" >> $GITHUB_ENV
56
+ echo "latest-release-name=$LATEST_RELEASE_NAME" >> $GITHUB_OUTPUT
57
+ echo "is-pre-release=$IS_PRE_RELEASE" >> $GITHUB_OUTPUT
58
+ if [ "$IS_PRE_RELEASE" == 'true' ]; then
59
+ echo "container-release-tag=pre" >> $GITHUB_OUTPUT
60
+ else
61
+ echo "container-release-tag=latest" >> $GITHUB_OUTPUT
62
+ fi
55
63
56
- - name : Fetch and checkout to release branch
57
- run : |
58
- git fetch --all
59
- git checkout ${{ vars.RELEASE_BRANCH_NAME }}
64
+ release-publish-npm :
65
+ needs : [ final-check-before-release ]
66
+ runs-on : ubuntu-latest
67
+ steps :
68
+ - name : Download source tree for the release
69
+ uses : actions/download-artifact@v4
70
+ with :
71
+ name : src
72
+ path : ${{ github.workspace }}
60
73
61
- - name : Publish to npm (pre-release)
62
- if : env.IS_PRE_RELEASE == 'true'
63
- run : npm publish --tag beta
74
+ - name : Extract source tree
75
+ run : tar xfz src.tar.gz
76
+
77
+ - name : Initialize npm config
78
+ run : npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
64
79
env :
65
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
66
- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
80
+ NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
67
81
68
82
- name : Publish to npm
69
- if : env.IS_PRE_RELEASE == 'false'
70
- run : npm publish
83
+ run : |
84
+ CMD="npm publish"
85
+ if [ "${{ needs.final-check-before-release.outputs.is-pre-release }}" == 'true' ]; then
86
+ CMD="$CMD --tag beta"
87
+ fi
88
+ $CMD
71
89
env :
72
90
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
73
91
NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
92
+
93
+ release-container-image :
94
+ needs : [ final-check-before-release ]
95
+ permissions :
96
+ packages : write
97
+ runs-on : ubuntu-latest
98
+ env :
99
+ REGISTRY : ghcr.io
100
+ steps :
101
+ - name : Download source tree for the release
102
+ uses : actions/download-artifact@v4
103
+ with :
104
+ name : src
105
+ path : ${{ github.workspace }}
106
+
107
+ - name : Extract source tree
108
+ run : tar xfz src.tar.gz
109
+
110
+ - name : Set up Docker Buildx
111
+ uses : docker/setup-buildx-action@v3
112
+
113
+ - name : Log in to the Container registry
114
+ uses : docker/login-action@v3
115
+ with :
116
+ registry : ${{ env.REGISTRY }}
117
+ username : ${{ github.actor }}
118
+ password : ${{ github.token }}
119
+
120
+ - name : Extract metadata (tags, labels)
121
+ id : meta
122
+ uses : docker/metadata-action@v5
123
+ with :
124
+ tags : |
125
+ type=raw,value=${{ needs.final-check-before-release.outputs.container-release-tag }}
126
+ type=raw,value=${{ needs.final-check-before-release.outputs.latest-release-name }}
127
+ type=sha
128
+ images : ${{ env.REGISTRY }}/${{ github.repository }}
129
+
130
+ - name : Build and push container image
131
+ uses : docker/build-push-action@v6
132
+ with :
133
+ platforms : linux/amd64,linux/arm64
134
+ push : true
135
+ tags : ${{ steps.meta.outputs.tags }}
136
+ labels : ${{ steps.meta.outputs.labels }}
137
+ provenance : false
0 commit comments