@@ -22,16 +22,19 @@ jobs:
22
22
- run : npm test
23
23
env :
24
24
FORCE_COLOR : 3
25
- - run : node scripts/prepublish-clean.mjs
25
+ - run : |
26
+ node scripts/build-jsr.mjs
27
+ node scripts/prepublish-clean.mjs
26
28
- uses : actions/upload-artifact@v4
27
29
with :
28
30
name : build-${{ github.run_id }}
29
31
path : |
30
32
build
31
33
package.json
34
+ jsr.json
32
35
retention-days : 1
33
36
34
- publish :
37
+ npm- publish :
35
38
needs : build
36
39
runs-on : ubuntu-latest
37
40
permissions :
40
43
contents : write
41
44
packages : write
42
45
id-token : write
46
+ env :
47
+ GOOGLE_NPM_REGISTRY : wombat-dressing-room.appspot.com
48
+ GOOGLE_NPM_TOKEN : ${{ secrets.AUTH_TOKEN }}
49
+ GH_NPM_REGISTRY : npm.pkg.github.com
50
+ GH_NPM_TOKEN : ${{ secrets.GITHUB_TOKEN }}
43
51
steps :
44
52
- uses : actions/checkout@v4
45
53
with :
@@ -48,13 +56,88 @@ jobs:
48
56
with :
49
57
node-version : 22
50
58
cache : ' npm'
59
+ - name : Get zx version info
60
+ run : echo ZX_VERSION=$(jq -r '.version' package.json) >> $GITHUB_ENV
61
+ - name : Configure npmrc
62
+ run : |
63
+ echo "//${{ env.GOOGLE_NPM_REGISTRY }}/:_authToken=$GOOGLE_NPM_TOKEN" >> .npmrc
64
+ echo "//${{ env.GH_NPM_REGISTRY }}/:_authToken=$GH_NPM_TOKEN" >> .npmrc
51
65
- uses : actions/download-artifact@v4
52
66
with :
53
67
name : build-${{ github.run_id }}
54
- - run : echo "//wombat-dressing-room.appspot.com/:_authToken=$AUTH_TOKEN" >> .npmrc
55
- env :
56
- AUTH_TOKEN : ${{ secrets.AUTH_TOKEN }}
57
- - run : |
58
- npm publish --provenance --access=public
68
+
69
+ - name : pushing to ${{ env.GOOGLE_NPM_REGISTRY }}
70
+ run : npm publish --provenance --access=public --registry https://${{ env.GOOGLE_NPM_REGISTRY }}
71
+
72
+ - name : pushing to ${{ env.GH_NPM_REGISTRY }}
73
+ run : |
74
+ cat <<< $(jq '.name="@${{ github.repository }}"' package.json) > package.json
75
+ npm publish --no-git-tag-version --access=public --registry https://${{ env.GH_NPM_REGISTRY }}
76
+
77
+ - name : pushing lite snapshot to ${{ env.GOOGLE_NPM_REGISTRY }}
78
+ run : |
79
+ cat <<< $(jq '.name="zx"' package.json) > package.json
59
80
node scripts/prepublish-lite.mjs
60
- npm publish --provenance --access=public --no-git-tag-version --tag lite
81
+ npm publish --provenance --access=public --no-git-tag-version --tag lite --registry https://${{ env.GOOGLE_NPM_REGISTRY }}
82
+
83
+ - name : pushing to jsr.io
84
+ run : npx jsr publish --allow-dirty
85
+
86
+ # https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images
87
+ docker-publish :
88
+ needs : build
89
+ runs-on : ubuntu-latest
90
+ # Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
91
+ env :
92
+ REGISTRY : ghcr.io
93
+ IMAGE_NAME : ${{ github.repository }}
94
+
95
+ # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
96
+ permissions :
97
+ contents : read
98
+ packages : write
99
+ attestations : write
100
+ id-token : write
101
+ steps :
102
+ - name : Checkout repository
103
+ uses : actions/checkout@v4
104
+ with :
105
+ persist-credentials : false
106
+
107
+ - uses : actions/download-artifact@v4
108
+ with :
109
+ name : build-${{ github.run_id }}
110
+
111
+ - name : Get zx version
112
+ run : echo ZX_VERSION=$(jq -r '.version' package.json) >> $GITHUB_ENV
113
+
114
+ - name : Log in to the Container registry
115
+ uses : docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
116
+ with :
117
+ registry : ${{ env.REGISTRY }}
118
+ username : ${{ github.actor }}
119
+ password : ${{ secrets.GITHUB_TOKEN }}
120
+ - name : Extract metadata (tags, labels) for Docker
121
+ id : meta
122
+ uses : docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804
123
+ with :
124
+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
125
+ tags : |
126
+ type=sha
127
+ type=semver,pattern={{version}},value=v${{ env.ZX_VERSION }}
128
+ - name : Build and push Docker image
129
+ id : push
130
+ uses : docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
131
+ with :
132
+ context : ./
133
+ file : ./dcr/Dockerfile
134
+ push : true
135
+ tags : ${{ steps.meta.outputs.tags }}
136
+ labels : ${{ steps.meta.outputs.labels }}
137
+
138
+ - name : Generate artifact attestation
139
+ uses : actions/attest-build-provenance@v2
140
+ with :
141
+ subject-name : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
142
+ subject-digest : ${{ steps.push.outputs.digest }}
143
+ push-to-registry : true
0 commit comments