Skip to content

Commit f2b3233

Browse files
authored
chore: auto publish (#112)
1 parent a893e39 commit f2b3233

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

.github/workflows/release-integration.yml

+16-7
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,24 @@ on:
1515
required: true
1616
type: string
1717
description: 'A json array of releases. Required fields: publish: tagName, publishTag. publish check: pkgName, version'
18+
secrets:
19+
PUBLISH_TOKEN:
20+
required: true
1821

1922
jobs:
2023
publish:
21-
name: Check Publish
24+
name: Publish
2225
runs-on: ubuntu-latest
2326
defaults:
2427
run:
2528
shell: bash
29+
permissions:
30+
id-token: write
2631
steps:
2732
- name: Checkout
2833
uses: actions/checkout@v4
34+
with:
35+
ref: ${{ fromJSON(inputs.releases)[0].tagName }}
2936
- name: Setup Git User
3037
run: |
3138
git config --global user.email "npm-cli+bot@github.com"
@@ -42,19 +49,21 @@ jobs:
4249
node: ${{ steps.node.outputs.node-version }}
4350
- name: Install Dependencies
4451
run: npm i --ignore-scripts --no-audit --no-fund
45-
- name: Check If Published
52+
- name: Set npm authToken
53+
run: npm config set '//registry.npmjs.org/:_authToken'=\${PUBLISH_TOKEN}
54+
- name: Publish
55+
env:
56+
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
57+
RELEASES: ${{ inputs.releases }}
4658
run: |
4759
EXIT_CODE=0
4860
4961
for release in $(echo $RELEASES | jq -r '.[] | @base64'); do
50-
SPEC="$(echo "$release" | base64 --decode | jq -r .pkgName)@$(echo "$release" | base64 --decode | jq -r .version)"
51-
npm view "$SPEC" --json
62+
PUBLISH_TAG=$(echo "$release" | base64 --decode | jq -r .publishTag)
63+
npm publish --provenance --tag="$PUBLISH_TAG"
5264
STATUS=$?
5365
if [[ "$STATUS" -eq 1 ]]; then
5466
EXIT_CODE=$STATUS
55-
echo "$SPEC ERROR"
56-
else
57-
echo "$SPEC OK"
5867
fi
5968
done
6069

.github/workflows/release.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ jobs:
131131
id: comment-text
132132
env:
133133
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134-
run: npm exec --offline -- template-oss-release-manager --pr="${{ needs.release.outputs.pr-number }}" --backport="" --defaultTag="latest"
134+
run: npm exec --offline -- template-oss-release-manager --pr="${{ needs.release.outputs.pr-number }}" --backport="" --defaultTag="latest" --publish
135135
- name: Append Release Manager Comment
136136
uses: peter-evans/create-or-update-comment@v3
137137
with:
@@ -243,6 +243,10 @@ jobs:
243243
name: Release Integration
244244
if: needs.release.outputs.releases
245245
uses: ./.github/workflows/release-integration.yml
246+
permissions:
247+
id-token: write
248+
secrets:
249+
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
246250
with:
247251
releases: ${{ needs.release.outputs.releases }}
248252

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
},
4949
"templateOSS": {
5050
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
51-
"version": "4.22.0"
51+
"version": "4.22.0",
52+
"publish": true
5253
},
5354
"tap": {
5455
"nyc-arg": [

0 commit comments

Comments
 (0)