Skip to content

Commit

Permalink
[ci] add infrastructure for automated releases/publish to npm (latest)
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Dumais <marc.dumais@ericsson.com>
  • Loading branch information
marcdumais-work committed Mar 18, 2024
1 parent 9c3c502 commit 436085d
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 31 deletions.
39 changes: 38 additions & 1 deletion .github/workflows/build.yml → .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
name: CI
name: CI/CD

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types:
- published

jobs:

Expand Down Expand Up @@ -74,3 +77,37 @@ jobs:

- name: Check format
run: yarn format:check

publish-next:
name: Publish 'next' packages to npm
needs: build-and-test
if: github.ref == 'refs/heads/master' && github.event_name == 'push' && github.repository == 'eclipse-cdt-cloud/theia-trace-extension'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- run: yarn --frozen-lockfile
- run: yarn publish:next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

publish-latest:
name: Publish 'latest' packages to npm
needs: build-and-test
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') && github.repository == 'eclipse-cdt-cloud/theia-trace-extension'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- run: yarn --frozen-lockfile
- run: yarn publish:latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
23 changes: 0 additions & 23 deletions .github/workflows/publish-next.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release

on:
push:
branches:
- master
paths:
- 'RELEASE'
pull_request:
types: [opened, synchronize]
branches:
- master
paths:
- 'RELEASE'

jobs:
gh-release:
name: GitHub release
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pipe-cd/actions-gh-release@v2.6.0
with:
release_file: 'RELEASE'
# Actions that run using the auto-generated GitHub token are
# not allowed to trigger a new workflow run. In this case we want
# the tag created by actions-gh-release to re-trigger the main workflow
# and result in publishing the package to npm.
# The following scopes are required when creating the committer token:
# - repo:status, repo_deployment, public_repo, read:org
# See here for more details:
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
token: ${{ secrets.GH_COMMITTER_TOKEN }}

8 changes: 8 additions & 0 deletions RELEASE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tag: v0.0.0

commitInclude:
parentOfMergeCommit: true

releaseNoteGenerator:
showAbbrevHash: true
showCommitter: false
6 changes: 0 additions & 6 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
"run": {
"stream": true
},
"publish": {
"forcePublish": true,
"graphType": "all",
"skipGit": true,
"registry": "https://registry.npmjs.org/"
},
"verifyAccess": false
}
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
"lint": "lerna run lint",
"lint:fix": "lerna run lint:fix",
"test": "lerna run test --",
"publish:latest": "lerna publish --registry=https://registry.npmjs.org/ --exact --no-git-tag-version --no-push",
"publish:latest": "lerna publish from-git --registry=https://registry.npmjs.org/ --exact --no-push --yes",
"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",
"version:major": "lerna version major --exact --no-push --git-tag-command /usr/bin/true --yes -m \"Release %s (Major)\"",
"version:minor": "lerna version minor --exact --no-push --git-tag-command /usr/bin/true --yes -m \"Release %s (Minor)\"",
"version:patch": "lerna version patch --exact --no-push --git-tag-command /usr/bin/true --yes -m \"Release %s (Patch)\"",
"format:write": "lerna run format:write",
"format:check": "lerna run format:check",
"browser": "yarn -s --cwd examples/browser",
Expand Down

0 comments on commit 436085d

Please sign in to comment.