Skip to content

Commit 0c1a31b

Browse files
MobymanIlya Egorov
andauthored
CI: Update for OIDC (#339)
Co-authored-by: Ilya Egorov <ilya.e@ton.org>
1 parent 4865cca commit 0c1a31b

File tree

2 files changed

+37
-78
lines changed

2 files changed

+37
-78
lines changed

.github/workflows/publish-dev.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,61 @@ on:
22
push:
33
branches:
44
- main
5+
- develop
6+
57
name: Publish to NPM
68
jobs:
79
publish:
810
name: Publish
911
runs-on: ubuntu-latest
10-
environment: prod
12+
environment: ${{ github.ref_name == 'main' && 'prod' || 'dev' }}
13+
14+
permissions:
15+
contents: read
16+
id-token: write
17+
1118
steps:
12-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v6
1320

1421
- name: Enable Corepack
1522
run: corepack enable
1623

1724
- name: Use Node.js 18
18-
uses: actions/setup-node@v3
25+
uses: actions/setup-node@v6
1926
with:
2027
node-version: '18.x'
21-
always-auth: true
2228

2329
- name: Install dependencies
2430
run: yarn install
2531

32+
- name: Bump version (dev)
33+
if: github.ref_name == 'develop'
34+
id: version
35+
run: |
36+
CURRENT_VERSION=$(jq -r '.version' package.json)
37+
BASE_VERSION=$(echo $CURRENT_VERSION | cut -d '-' -f 1)
38+
39+
NEW_BASE=$(echo $BASE_VERSION | awk -v OFS='.' -F. '{
40+
$2 = $2 + 1;
41+
$3 = 0;
42+
print $0
43+
}')
44+
45+
TIMESTAMP=$(date -u +"%Y%m%d%H%M%S")
46+
COMMIT_SHA=$(git rev-parse --short HEAD)
47+
NEW_VERSION="${NEW_BASE}-dev.${TIMESTAMP}.${COMMIT_SHA}"
48+
49+
jq ".version = \"$NEW_VERSION\"" package.json > package.tmp
50+
mv package.tmp package.json
51+
2652
- name: Build
2753
run: yarn run build
2854

29-
- name: Setup .yarnrc.yml
30-
run: |
31-
yarn config set npmAuthToken $NPM_AUTH_TOKEN
32-
yarn config set npmAlwaysAuth true
33-
env:
34-
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
35-
3655
- name: Publish
37-
env:
38-
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
39-
run: yarn npm publish --access public
56+
run: |
57+
npm config delete //registry.npmjs.org/:_authToken || true
58+
if [ "${{ github.ref_name }}" = "develop" ]; then
59+
npm publish --provenance --access public --tag dev
60+
else
61+
npm publish --provenance --access public
62+
fi

0 commit comments

Comments
 (0)