-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (120 loc) · 4.75 KB
/
publish-dev.yaml
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Publish Dev
on:
push:
branches-ignore:
# Hopefully used for github pages deployments in future
- gh-pages
# Personal branch to create PRs from
- jley-*
jobs:
# This workflow triggers on push, so there is no simple concept of "diff"
# So no need to pass base/head refs (will _always_ trigger internal lint/test)
build-and-test:
uses: ./.github/workflows/build-and-test.yaml
publish-dev:
needs: build-and-test
runs-on: ubuntu-latest
strategy:
matrix:
package:
- name: default-import
safe-name: default-import
path: tools/default-import
- name: enum-to-array
safe-name: enum-to-array
path: tools/enum-to-array
- name: iso-crypto
safe-name: iso-crypto
path: tools/iso-crypto
- name: named-patch
safe-name: named-patch
path: tools/named-patch
- name: normalized-react-query
safe-name: normalized-react-query
path: tools/normalized-react-query
- name: parse-cwd
safe-name: parse-cwd
path: tools/parse-cwd
- name: punycode-esm
safe-name: punycode-esm
path: tools/punycode-esm
- name: static-emitter
safe-name: static-emitter
path: tools/static-emitter
- name: entry-script
safe-name: entry-script
path: tools/entry-script
- name: find-import
safe-name: find-import
path: tools/find-import
- name: juniper
safe-name: juniper
path: apps/juniper
- name: barrelify
safe-name: barrelify
path: apps/barrelify
- name: root-package-json
safe-name: root-package-json
path: tools/root-package-json
- name: packages-list
safe-name: packages-list
path: tools/packages-list
- name: dependency-order
safe-name: dependency-order
path: tools/dependency-order
- name: rivendell
safe-name: rivendell
path: apps/rivendell
steps:
- uses: actions/checkout@v3
# Artifact includes node_modules + all built packages
- uses: actions/download-artifact@v3
with:
name: build
- uses: actions/setup-node@v3
with:
node-version: 16
- run: |
for TARBALL in ./tarballs/*.tgz
do
tar -xf $TARBALL
done
# Authorize NPM + download jq (CLI for JSON parsing + manipulation)
- run: |
echo //registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }} >> ~/.npmrc
sudo apt-get install jq
# Update `file://...` "versions" for local dependencies, then publish
- working-directory: ${{ matrix.package.path }}
run: |
# Get raw version (without dev suffix)
VERSION=`cat ./package.json | jq '.version' -r`
# Add dev suffix (based on hash) to all relevant packages
node ${{ github.workspace }}/common/scripts/install-run-rush.js set-dev-version --project ${{ matrix.package.name }}
# Read dev suffix, and check if version already exists
DEV_VERSION=`cat ./package.json | jq '.version' -r`
EXISTS=`${{ github.workspace }}/common/scripts/package-exists.mjs ${{ matrix.package.name }} $DEV_VERSION`
if [[ $EXISTS == true ]]
then
# If version already exists, publish is NOOP at best (fails at worst) so quit early
exit 0
fi
# Tack on generic License + npmignore
node ${{ github.workspace }}/common/scripts/install-run-rush.js write-publish
# Non-main branches should still publish, but never as "dev". "ignore" tag will be cleaned up.
if [[ ${{ github.ref_name }} == main ]]
then
TAG=dev
else
TAG=ignore
fi
# First publish with git sha (this version will be re-published if released, easiest to lookup in github action)
npm pkg set version=$VERSION-dev.${{ github.sha }}
${{ github.workspace }}/common/temp/pnpm-local/node_modules/.bin/pnpm publish --no-git-checks --tag ignore
# Reset version to hash
npm pkg set version=$DEV_VERSION
# Indicate "paired" package for easy lookup
npm pkg set gitsha=${{ github.sha }}
# Publish with hash
${{ github.workspace }}/common/temp/pnpm-local/node_modules/.bin/pnpm publish --no-git-checks --tag $TAG
# Cleanup "ignore" tag
${{ github.workspace }}/common/temp/pnpm-local/node_modules/.bin/pnpm dist-tag rm ${{ matrix.package.name }} ignore