Skip to content

Commit 2384180

Browse files
authored
Merge pull request #368 from currents-dev/maxi/eng-556-enable-linear-release-process-for-currents-reporter
chore: integrate Linear Releases with multi-package workflow
2 parents 5271a71 + aef0f44 commit 2384180

3 files changed

Lines changed: 179 additions & 0 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Linear Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '@currents/cmd-v*'
7+
- '@currents/jest-v*'
8+
- '@currents/node-test-reporter-v*'
9+
branches:
10+
- main
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
linear-release:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
# Main branch: sync to all package pipelines
24+
- name: Sync main branch to Linear (cmd)
25+
if: github.ref_type == 'branch' && github.ref_name == 'main'
26+
uses: linear/linear-release-action@v0
27+
with:
28+
access_key: ${{ secrets.LINEAR_ACCESS_KEY_CMD }}
29+
30+
- name: Sync main branch to Linear (jest)
31+
if: github.ref_type == 'branch' && github.ref_name == 'main'
32+
uses: linear/linear-release-action@v0
33+
with:
34+
access_key: ${{ secrets.LINEAR_ACCESS_KEY_JEST }}
35+
36+
- name: Sync main branch to Linear (node-test-reporter)
37+
if: github.ref_type == 'branch' && github.ref_name == 'main'
38+
uses: linear/linear-release-action@v0
39+
with:
40+
access_key: ${{ secrets.LINEAR_ACCESS_KEY_NODE_TEST_REPORTER }}
41+
42+
# Tag pushed: extract package name and version
43+
- name: Extract package and version from tag
44+
if: github.ref_type == 'tag'
45+
id: extract_tag
46+
run: |
47+
TAG="${GITHUB_REF#refs/tags/}"
48+
# Format: @currents/PACKAGE_NAME-vVERSION
49+
# Use digit anchor to correctly capture multi-hyphen package names
50+
if [[ $TAG =~ ^@currents/(.+)-v([0-9]+\..+)$ ]]; then
51+
PACKAGE="${BASH_REMATCH[1]}"
52+
VERSION="${BASH_REMATCH[2]}"
53+
echo "package=$PACKAGE" >> $GITHUB_OUTPUT
54+
echo "version=$VERSION" >> $GITHUB_OUTPUT
55+
echo "tag=$TAG" >> $GITHUB_OUTPUT
56+
else
57+
echo "Error: Tag '$TAG' does not match expected format '@currents/PACKAGE-vVERSION'"
58+
exit 1
59+
fi
60+
61+
# Determine Linear access key based on package
62+
- name: Set Linear access key
63+
if: github.ref_type == 'tag'
64+
id: linear_key
65+
run: |
66+
PACKAGE="${{ steps.extract_tag.outputs.package }}"
67+
case "$PACKAGE" in
68+
cmd)
69+
echo "key=LINEAR_ACCESS_KEY_CMD" >> $GITHUB_OUTPUT
70+
;;
71+
jest)
72+
echo "key=LINEAR_ACCESS_KEY_JEST" >> $GITHUB_OUTPUT
73+
;;
74+
node-test-reporter)
75+
echo "key=LINEAR_ACCESS_KEY_NODE_TEST_REPORTER" >> $GITHUB_OUTPUT
76+
;;
77+
*)
78+
echo "Error: Unknown package '$PACKAGE'"
79+
exit 1
80+
;;
81+
esac
82+
83+
# Sync tag to Linear with package-specific key
84+
- name: Sync tag to Linear
85+
if: github.ref_type == 'tag'
86+
uses: linear/linear-release-action@v0
87+
with:
88+
access_key: ${{ secrets[steps.linear_key.outputs.key] }}
89+
version: ${{ steps.extract_tag.outputs.version }}

.github/workflows/publish.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ permissions:
2626
id-token: write # Required for OIDC
2727
contents: read
2828

29+
env:
30+
PACKAGE_MAP: |
31+
{
32+
"@currents/cmd": "cmd",
33+
"@currents/jest": "jest",
34+
"@currents/node-test-reporter": "node-test-reporter"
35+
}
36+
2937
jobs:
3038
publish:
3139
runs-on: ubuntu-latest
@@ -43,9 +51,69 @@ jobs:
4351
node-version: '24.x'
4452
registry-url: 'https://registry.npmjs.org'
4553

54+
- name: Extract package version
55+
id: extract_version
56+
env:
57+
PACKAGE_INPUT: ${{ github.event.inputs.package }}
58+
run: |
59+
PACKAGE_SHORT_NAME=$(node -e "const m = JSON.parse(process.env.PACKAGE_MAP); console.log(m[process.env.PACKAGE_INPUT])")
60+
PACKAGE_VERSION=$(node -p "require('./packages/$PACKAGE_SHORT_NAME/package.json').version")
61+
echo "version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
62+
echo "package_short=$PACKAGE_SHORT_NAME" >> $GITHUB_OUTPUT
63+
4664
- run: npm ci
4765
- name: Publish to NPM
4866
run: |
4967
git config user.name "Currents NPM Bot"
5068
git config user.email "npm@currents.dev"
5169
npm run publish:npm --workspace ${{ github.event.inputs.package }} -- --tag ${{ github.event.inputs.channel }}
70+
71+
- name: Determine Linear access key
72+
id: linear_key
73+
if: success() && github.event.inputs.channel == 'latest'
74+
run: |
75+
PACKAGE_SHORT="${{ steps.extract_version.outputs.package_short }}"
76+
case "$PACKAGE_SHORT" in
77+
cmd)
78+
echo "key=LINEAR_ACCESS_KEY_CMD" >> $GITHUB_OUTPUT
79+
;;
80+
jest)
81+
echo "key=LINEAR_ACCESS_KEY_JEST" >> $GITHUB_OUTPUT
82+
;;
83+
node-test-reporter)
84+
echo "key=LINEAR_ACCESS_KEY_NODE_TEST_REPORTER" >> $GITHUB_OUTPUT
85+
;;
86+
*)
87+
echo "Error: Unknown package '$PACKAGE_SHORT'"
88+
exit 1
89+
;;
90+
esac
91+
92+
- name: Mark Linear release as complete
93+
id: release
94+
if: success() && github.event.inputs.channel == 'latest'
95+
uses: linear/linear-release-action@v0
96+
with:
97+
access_key: ${{ secrets[steps.linear_key.outputs.key] }}
98+
command: complete
99+
version: ${{ steps.extract_version.outputs.version }}
100+
101+
- name: Post to Slack
102+
if: success() && github.event.inputs.channel == 'latest' && steps.release.outputs.release-url
103+
uses: slackapi/slack-github-action@v2
104+
with:
105+
webhook: ${{ secrets.SLACK_RELEASE_WEBHOOK_URL }}
106+
webhook-type: incoming-webhook
107+
payload: |
108+
{
109+
"text": "🚀 Release: ${{ github.event.inputs.package }}@${{ steps.extract_version.outputs.version }}",
110+
"blocks": [
111+
{
112+
"type": "section",
113+
"text": {
114+
"type": "mrkdwn",
115+
"text": "*🚀 Release: ${{ github.event.inputs.package }}@${{ steps.extract_version.outputs.version }}* has been marked as complete in Linear.\n\n<${{ steps.release.outputs.release-url }}|View Release Notes>"
116+
}
117+
}
118+
]
119+
}

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,28 @@ npm run release
100100

101101
You can create a PR from the release branch to be merged after publish.
102102

103+
### Linear Releases Integration
104+
105+
The release process integrates with Linear Releases to track release scope, status, and changelog for each package:
106+
107+
- **Main branch push:** When changes are pushed to main, they're automatically synced to the current started release in Linear for each respective package
108+
- **Release tag push:** When a release tag (e.g., `@currents/cmd-v1.9.10`) is pushed, all commits since the previous tag are scanned and synced to the corresponding Linear release pipeline
109+
- **Release completion:** When publishing to npm via the "Publish NPM Package" workflow with `latest` channel, the release is automatically marked as complete in Linear and posted to Slack
110+
111+
When publishing to the latest channel, the workflow will:
112+
113+
- Mark the release as complete in Linear using the package-specific pipeline access key
114+
- Post a release announcement to Slack with a link to view release notes in Linear
115+
116+
**Required secrets:**
117+
118+
- `LINEAR_ACCESS_KEY_CMD` — pipeline-scoped access key for @currents/cmd releases
119+
- `LINEAR_ACCESS_KEY_JEST` — pipeline-scoped access key for @currents/jest releases
120+
- `LINEAR_ACCESS_KEY_NODE_TEST_REPORTER` — pipeline-scoped access key for @currents/node-test-reporter releases
121+
- `SLACK_RELEASE_WEBHOOK_URL` — Slack incoming webhook for posting messages
122+
123+
**Note:** Each pipeline access key is scoped to your specific release pipeline in Linear, ensuring operations only affect that pipeline.
124+
103125
## Publishing
104126

105127
Dispatch the GitHub Actions Workflow to publish new releases: https://github.com/currents-dev/currents-reporter/actions/workflows/publish.yaml

0 commit comments

Comments
 (0)