-
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (77 loc) · 2.83 KB
/
publish-npm-packages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: publish-npm
on:
release:
types: [created]
jobs:
secrets-gate:
runs-on: ubuntu-latest
outputs:
ok: ${{ steps.check-secrets.outputs.ok }}
steps:
- name: check for secrets needed to run workflows
id: check-secrets
run: |
if [ ${{ secrets.PUBLISH_NPM_PACKAGES_ENABLED }} == 'true' ]; then
echo "::set-output name=ok::enabled"
fi
publish-npm:
needs:
- secrets-gate
if: ${{ needs.secrets-gate.outputs.ok == 'enabled' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: https://npm.pkg.github.com/
scope: '@XRFoundation'
- name: Config npm registry token
run: npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Set git username
run: git config user.name "CI Bot"
- name: Set git email
run: git config user.email ci-bot@xrengine.io
- name: Set pr_branch_name environemt variable
run: echo pr_branch_name=version-increment-${{ github.event.release.tag_name }} >> $GITHUB_ENV
- name: Switch to branch ${{ env.pr_branch_name }}
run: git switch -c ${{ env.pr_branch_name }}
- name: Lerna increment version
run: npm run version-increment-no-tag ${{ github.event.release.tag_name }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Run git add
run: git add .
- name: Commit changes
run: git commit -m ${{ github.event.release.tag_name }}
- name: Push changes to new branch
run: git push --no-verify origin ${{ env.pr_branch_name }}
- name: Create version bump PR
uses: repo-sync/pull-request@v2
with:
destination_branch: ${{ github.event.release.target_commitish }}
github_token: ${{ secrets.GITHUB_TOKEN }}
source_branch: ${{ env.pr_branch_name }}
pr_title: ${{ github.event.release.tag_name }}
pr_body: Bump version to ${{ github.event.release.tag_name }}
- name: Publish to npm
run: npm run publish-no-verify
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Update package repo to GitHub Packages
run: npm run update-name-gh-package
- name: Run git add
run: git add .
- name: Commit changes
run: git commit -m 'GH Packages'
- name: Config npm registry token
run: npm config set '//npm.pkg.github.com/:_authToken' "${NPM_TOKEN}"
env:
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to GitHub Packages
run: npm run publish-github
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}