Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit bcfd5ff

Browse files
authored
Update publish branch workflow to use selfhosted registry (#164)
1 parent fb50ec2 commit bcfd5ff

File tree

1 file changed

+43
-24
lines changed

1 file changed

+43
-24
lines changed
Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,60 @@
11
name: "publish-branch"
22

33
on:
4-
workflow_dispatch
4+
workflow_dispatch:
55

66
jobs:
77
npm-publish:
88
name: "Publish"
99
runs-on: ubuntu-latest
10-
defaults:
11-
run:
12-
shell: bash
10+
11+
permissions:
12+
contents: read
13+
id-token: write
1314

1415
steps:
15-
- name: Checkout repository
16-
uses: actions/checkout@v2
16+
- uses: actions/checkout@v3
1717

18-
- name: Get branch name
19-
run: |
20-
BRANCH=${GITHUB_REF#refs/*/}
21-
SANITIZED=$(echo "$BRANCH" | sed -e 's/[^a-zA-Z0-9-]/-/g')
22-
echo "BRANCH_NAME=$SANITIZED" >> $GITHUB_ENV
23-
### Set version
24-
- name: Set version
25-
run: npm version prerelease --no-git-tag-version --preid ${{ env.BRANCH_NAME }}-${{ github.run_number }}
26-
27-
### Publish to NPM registry
28-
- uses: actions/setup-node@v1
18+
- name: "Setup node with self-hosted npm registry"
19+
uses: actions/setup-node@v2
2920
with:
30-
node-version: '16'
31-
registry-url: 'https://registry.npmjs.org'
21+
node-version: "16"
22+
registry-url: "https://npm.fluence.dev"
3223

33-
- run: cat package.json
34-
35-
- run: npm i
24+
- run: npm ci
3625
- run: npm run build
3726

38-
- run: npm publish --access public --tag=beta
27+
- name: "Import secrets"
28+
uses: hashicorp/vault-action@v2.4.2
29+
with:
30+
url: https://vault.fluence.dev
31+
path: jwt/github
32+
role: ci
33+
method: jwt
34+
jwtGithubAudience: "https://github.com/fluencelabs"
35+
jwtTtl: 300
36+
exportToken: false
37+
secrets: |
38+
kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN
39+
40+
- name: "Generate package version"
41+
id: version
42+
run: |
43+
BRANCH=${GITHUB_REF#refs/heads/}
44+
SHA=$(git rev-parse --short HEAD)
45+
46+
echo "::set-output name=sha::$SHA"
47+
echo "::set-output name=branch::${BRANCH//[^a-zA-Z0-9-]/-}"
48+
49+
- name: "Set package version"
3950
env:
40-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
51+
BRANCH: ${{ steps.version.outputs.branch }}
52+
SHA: ${{ steps.version.outputs.sha }}
53+
RUN: ${{ github.run_number }}
54+
ATTEMPT: ${{ github.run_attempt }}
55+
run: |
56+
npm version prerelease --no-git-tag-version \
57+
--preid ${{ env.BRANCH }}-${{ env.SHA }}-${{ env.RUN }}-${{ env.ATTEMPT }}
4158
59+
- name: "Publish to self-hosted npm repo"
60+
run: npm publish --tag snapshot --registry https://npm.fluence.dev

0 commit comments

Comments
 (0)