Skip to content

Commit

Permalink
[CI] Add release workflow/job and publish-latest job
Browse files Browse the repository at this point in the history
The new release workflow uses action "pipe-cd/actions-gh-release". This
action uses file RELEASE in the root. When that file is modified in a PR,
and contains a new release tag, it will trigger a release upon the PR
being merged. The action will create a git tag in the repo and the
corresponding GitHub release, containing auto-generated release notes,
that can be later edited by a committer.

The new release will in turn trigger the new "publish-latest" job
(ci-cd workflow), which will publish the new version of the package to
npm.

Signed-off-by: Marc Dumais <marc.dumais@ericsson.com>
  • Loading branch information
marcdumais-work committed Mar 1, 2024
1 parent 78f19d5 commit 126b406
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 20 deletions.
46 changes: 42 additions & 4 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ on:
branches:
- master
workflow_dispatch:

release:
types:
- published

jobs:
build:
Expand Down Expand Up @@ -38,7 +40,7 @@ jobs:
yarn
env:
NODE_OPTIONS: "--max_old_space_size=4096"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # https://github.com/microsoft/vscode-ripgrep/issues/9
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Test
shell: bash
Expand All @@ -47,7 +49,7 @@ jobs:
env:
NODE_OPTIONS: "--max_old_space_size=4096"

publish:
publish-next:
needs: build
if: github.ref == 'refs/heads/master' && github.event_name == 'push' && github.repository == 'eclipse-cdt-cloud/timeline-chart'

Expand Down Expand Up @@ -75,7 +77,7 @@ jobs:
yarn
env:
NODE_OPTIONS: --max_old_space_size=4096
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # https://github.com/microsoft/vscode-ripgrep/issues/9
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish
uses: nick-invision/retry@v2
Expand All @@ -87,3 +89,39 @@ jobs:
command: yarn publish:next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # The variable name comes from here: https://github.com/actions/setup-node/blob/70b9252472eee7495c93bb1588261539c3c2b98d/src/authutil.ts#L48

publish-latest:
needs: build
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') && github.repository == 'eclipse-cdt-cloud/timeline-chart'
runs-on: ubuntu-latest
strategy:
matrix:
node: [16]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
registry-url: 'https://registry.npmjs.org'
- name: Pre-Publish
shell: bash
run: |
yarn
env:
NODE_OPTIONS: --max_old_space_size=4096
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
retry_wait_seconds: 60
max_attempts: 3
retry_on: error
command: yarn publish:latest:ci
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # The variable name comes from here: https://github.com/actions/setup-node/blob/70b9252472eee7495c93bb1588261539c3c2b98d/src/authutil.ts#L48

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: Create or prepare GitHub 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
21 changes: 5 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"version": "0.1.0",
"private": true,
"license": "MIT",
"scripts": {
Expand All @@ -8,25 +7,15 @@
"watch": "lerna run watch",
"start": "lerna run start",
"test": "lerna run test --",
"publish:latest": "lerna publish --registry=https://registry.npmjs.org/ --exact --no-git-tag-version --no-push",
"publish:latest:ci": "lerna publish from-git --registry=https://registry.npmjs.org/ --exact --no-push --yes",
"publish:latest:manual": "lerna publish --registry=https://registry.npmjs.org/ --exact --no-git-tag-version --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)\"",
"license:check": "npx dash-licenses-wrapper --configFile=./configs/license-check-config.json",
"license:check:review": "npx dash-licenses-wrapper --configFile=./configs/license-check-config.json --review"
},
"keywords": [
"gantt",
"timeline",
"tracing",
"trace"
],
"repository": {
"type": "git",
"url": "https://github.com/theia-ide/timeline-chart"
},
"bugs": {
"url": "https://github.com/theia-ide/timeline-chart/issues"
},
"homepage": "https://github.com/theia-ide/timeline-chart",
"devDependencies": {
"@eclipse-dash/nodejs-wrapper": "^0.0.1",
"lerna": "^7.0.0",
Expand Down

0 comments on commit 126b406

Please sign in to comment.