-
Notifications
You must be signed in to change notification settings - Fork 44
81 lines (65 loc) · 2.65 KB
/
publishPackages.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
80
81
name: Publish Packages
on:
workflow_dispatch:
inputs:
package:
description: 'Comma-separated packages names'
required: true
version:
description: 'Package version (defaults to `prerelease`)'
default: 'prerelease'
required: false
jobs:
update_version:
# run only on master branch
if: github.ref == 'refs/heads/master'
name: Publish Single Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- run: yarn npm whoami
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: yarn install --immutable --immutable-cache
- name: Config git identity
run: |
git config --global user.email "ci@snxdao.io"
git config --global user.name "Synthetix CI"
- run: yarn deps:version '${{ github.event.inputs.package }}' ${{ github.event.inputs.version }}
- run: yarn version apply --all
- run: yarn build
- name: Create git tag and commit changes
run: |
git diff --name-only '**/package.json' > /tmp/changed-packages.txt
cat /tmp/changed-packages.txt
echo -n > /tmp/commit-message.txt
echo 'Updated packages:' >> /tmp/commit-message.txt
for WORKSPACE_PACKAGE in $(cat /tmp/changed-packages.txt); do
WORKSPACE_NAME=$(jq --raw-output '.name' < $WORKSPACE_PACKAGE)
WORKSPACE_VERSION=$(jq --raw-output '.version' < $WORKSPACE_PACKAGE)
echo " - $WORKSPACE_NAME@$WORKSPACE_VERSION" >> /tmp/commit-message.txt
done
cat /tmp/commit-message.txt
git commit --allow-empty --no-verify --all --file /tmp/commit-message.txt
# We are currently not using tags in any way so not much sense pushing tags to the repo
# TODO: uncomment if we want to add tags
# for WORKSPACE_PACKAGE in $(cat /tmp/changed-packages.txt); do
# WORKSPACE_NAME=$(jq --raw-output '.name' < $WORKSPACE_PACKAGE)
# WORKSPACE_VERSION=$(jq --raw-output '.version' < $WORKSPACE_PACKAGE)
# git tag -a "$WORKSPACE_NAME@$WORKSPACE_VERSION" -m "$WORKSPACE_NAME@$WORKSPACE_VERSION"
# done
- name: Publish packages
run: yarn workspaces foreach --no-private npm publish --tolerate-republish
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Push with tags
# - run: git push --follow-tags
# Push without tags
- run: git push