Skip to content

Commit d68a2c6

Browse files
[wip] [ci] add infrastructure for automated releases/publish to npm (latest)
Signed-off-by: Marc Dumais <marc.dumais@ericsson.com>
1 parent d1616c4 commit d68a2c6

File tree

6 files changed

+87
-31
lines changed

6 files changed

+87
-31
lines changed
Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
name: CI
1+
name: CI/CD
22

33
on:
44
push:
55
branches: [ master ]
66
pull_request:
77
branches: [ master ]
8+
release:
9+
types:
10+
- published
811

912
jobs:
1013

@@ -74,3 +77,37 @@ jobs:
7477

7578
- name: Check format
7679
run: yarn format:check
80+
81+
publish-next:
82+
name: Publish 'next' packages to npm
83+
needs: build-and-test
84+
if: github.ref == 'refs/heads/master' && github.event_name == 'push' && github.repository == 'eclipse-cdt-cloud/theia-trace-extension'
85+
runs-on: ubuntu-latest
86+
steps:
87+
- uses: actions/checkout@v4
88+
# Setup .npmrc file to publish to npm
89+
- uses: actions/setup-node@v4
90+
with:
91+
node-version: '18'
92+
registry-url: 'https://registry.npmjs.org'
93+
- run: yarn --frozen-lockfile
94+
- run: yarn publish:next
95+
env:
96+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
97+
98+
publish-latest:
99+
name: Publish 'latest' packages to npm
100+
needs: build-and-test
101+
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') && github.repository == 'eclipse-cdt-cloud/theia-trace-extension'
102+
runs-on: ubuntu-latest
103+
steps:
104+
- uses: actions/checkout@v4
105+
# Setup .npmrc file to publish to npm
106+
- uses: actions/setup-node@v4
107+
with:
108+
node-version: '18'
109+
registry-url: 'https://registry.npmjs.org'
110+
- run: yarn --frozen-lockfile
111+
- run: yarn publish:latest:ci
112+
env:
113+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

.github/workflows/publish-next.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- 'RELEASE'
9+
pull_request:
10+
types: [opened, synchronize]
11+
branches:
12+
- master
13+
paths:
14+
- 'RELEASE'
15+
16+
jobs:
17+
gh-release:
18+
name: GitHub release
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0
25+
- uses: pipe-cd/actions-gh-release@v2.6.0
26+
with:
27+
release_file: 'RELEASE'
28+
# Actions that run using the auto-generated GitHub token are
29+
# not allowed to trigger a new workflow run. In this case we want
30+
# the tag created by actions-gh-release to re-trigger the main workflow
31+
# and result in publishing the package to npm.
32+
# The following scopes are required when creating the committer token:
33+
# - repo:status, repo_deployment, public_repo, read:org
34+
# See here for more details:
35+
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
36+
token: ${{ secrets.GH_COMMITTER_TOKEN }}
37+

RELEASE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tag: v0.0.0
2+
3+
commitInclude:
4+
parentOfMergeCommit: true
5+
6+
releaseNoteGenerator:
7+
showAbbrevHash: true
8+
showCommitter: false

lerna.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
"run": {
77
"stream": true
88
},
9-
"publish": {
10-
"forcePublish": true,
11-
"graphType": "all",
12-
"skipGit": true,
13-
"registry": "https://registry.npmjs.org/"
14-
},
159
"verifyAccess": false
1610
}
1711
}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
"lint": "lerna run lint",
2020
"lint:fix": "lerna run lint:fix",
2121
"test": "lerna run test --",
22-
"publish:latest": "lerna publish --registry=https://registry.npmjs.org/ --exact --no-git-tag-version --no-push",
22+
"publish:latest": "lerna publish from-git --registry=https://registry.npmjs.org/ --exact --no-push --yes",
2323
"publish:next": "lerna publish --registry=https://registry.npmjs.org/ --exact --canary minor --preid=next.$(date -u '+%Y%m%d%H%M%S').$(git rev-parse --short HEAD) --dist-tag=next --no-git-tag-version --no-push --yes",
24+
"version:major": "lerna version major --exact --no-push --git-tag-command /usr/bin/true --yes -m \"Release %s (Major)\"",
25+
"version:minor": "lerna version minor --exact --no-push --git-tag-command /usr/bin/true --yes -m \"Release %s (Minor)\"",
26+
"version:patch": "lerna version patch --exact --no-push --git-tag-command /usr/bin/true --yes -m \"Release %s (Patch)\"",
2427
"format:write": "lerna run format:write",
2528
"format:check": "lerna run format:check",
2629
"browser": "yarn -s --cwd examples/browser",

0 commit comments

Comments
 (0)