Skip to content

Commit f9e0d30

Browse files
committed
Add automated release workflows (#853)
This commit also contains new code introduced after the PR in #853 was merged. I just squashed it all together to prevent noisy commits to try and fix CI. The funny thing is that now the final commit looks fairly stupid/simple but it wasn't that easy as I would have liked. 1. Couldn't find a proper way to execute `npm version` using yarn workspaces. `yarn workspaces foreach npm version` would have worked if we were using Yarn 2 instead of Yarn 1. 2. Introducing `version` and `publish` scripts in both packages worked, but then the default `version` and `publish` were also executed. 3. Once I made the scripts unique (`npm-version`, `npm-publish`) it worked~ish. The registry was always set to a yarnpkg registry, even if we set the registry in CI and in a local .npmrc file. My guess is that we are executing in a nested directory and therefore it didn't work. 4. Next, I found the `npm workspaces` option so that we can use that in addition to `yarn workspaces` 🙃 5. In CI of course this didn't work, because I was not using the same node version... 6. After everything worked, I did cleanup of the new scripts, and removed the introduced .npmrc files.
1 parent aa1a48c commit f9e0d30

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

.github/workflows/release-dev.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Release Dev
2+
3+
on:
4+
push:
5+
branches: [develop]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
matrix:
13+
node-version: [16]
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: Use Node.js ${{ matrix.node-version }}
19+
uses: actions/setup-node@v2
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
registry-url: 'https://registry.npmjs.org'
23+
24+
- name: Use cached node_modules
25+
id: cache
26+
uses: actions/cache@v2
27+
with:
28+
path: '**/node_modules'
29+
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-modules-${{ hashFiles('**/yarn.lock') }}
30+
restore-keys: |
31+
nodeModules-
32+
33+
- name: Install dependencies
34+
run: yarn install --frozen-lockfile
35+
env:
36+
CI: true
37+
38+
- name: Test
39+
run: npm test
40+
env:
41+
CI: true
42+
43+
- name: Resolve version
44+
id: vars
45+
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
46+
47+
- name: "Version based on commit: 0.0.0-dev.${{ steps.vars.outputs.sha_short }}"
48+
run: npm version -w packages 0.0.0-dev.${{ steps.vars.outputs.sha_short }} --force --no-git-tag-version
49+
50+
- name: Publish
51+
run: npm publish -w packages --tag dev
52+
env:
53+
CI: true
54+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release-next.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Release Dev
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
matrix:
13+
node-version: [16]
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: Use Node.js ${{ matrix.node-version }}
19+
uses: actions/setup-node@v2
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
registry-url: 'https://registry.npmjs.org'
23+
24+
- name: Use cached node_modules
25+
id: cache
26+
uses: actions/cache@v2
27+
with:
28+
path: '**/node_modules'
29+
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-modules-${{ hashFiles('**/yarn.lock') }}
30+
restore-keys: |
31+
nodeModules-
32+
33+
- name: Install dependencies
34+
run: yarn install --frozen-lockfile
35+
env:
36+
CI: true
37+
38+
- name: Test
39+
run: npm test
40+
env:
41+
CI: true
42+
43+
- name: Resolve version
44+
id: vars
45+
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
46+
47+
- name: "Version based on commit: 0.0.0-next.${{ steps.vars.outputs.sha_short }}"
48+
run: npm version -w packages 0.0.0-next.${{ steps.vars.outputs.sha_short }} --force --no-git-tag-version
49+
50+
- name: Publish
51+
run: npm publish -w packages --tag next
52+
env:
53+
CI: true
54+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55+

0 commit comments

Comments
 (0)