-
-
Notifications
You must be signed in to change notification settings - Fork 18
63 lines (63 loc) · 2.2 KB
/
publish-workflow.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
name: Publish Package
on:
release:
types: [released]
jobs:
npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "12.x"
registry-url: "https://registry.npmjs.org"
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Install dependencies
run: yarn
- name: Put version to package.json
run: |
sed -i s/"\"version\":.*/\"version\": \"$RELEASE_VERSION\","/ package.json
- name: Update Publish Config
run: sed -i 's^registry-url^registry.npmjs.org^' package.json
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
ghp:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Store lowercase actor name
run: |
echo 'actor_name<<EOF' >> $GITHUB_ENV
echo ${{ github.actor }} | tr "A-Z" "a-z" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Store package name
run: |
echo 'package_name<<EOF' >> $GITHUB_ENV
grep -Po '"name": *\K"[^"]*"' package.json | grep -oP '"\K[^"\047]+(?=["\047])' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- uses: actions/setup-node@v1
with:
node-version: "12.x"
registry-url: https://npm.pkg.github.com
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Install dependencies
run: yarn
- name: Put version to package.json
run: |
sed -i s/"\"version\":.*/\"version\": \"$RELEASE_VERSION\","/ package.json
- name: Update Package Name
run: |
sed -i 's,"name": "${{ env.package_name }}","name": "@${{ env.actor_name }}/${{ env.package_name }}",' package.json
cat package.json
- name: Update Publish Config
run: |
sed -i 's^registry-url^npm.pkg.github.com/@${{ env.actor_name }}^' package.json
cat package.json
- name: Publish to GHP
run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.OR_RELEASE_TOKEN }}