Skip to content

Commit 5206bd8

Browse files
authored
ci: setup release pipeline (#5)
Release-As: 0.0.1
1 parent 2c9456b commit 5206bd8

File tree

3 files changed

+103
-1
lines changed

3 files changed

+103
-1
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v2
11-
- name: Use Node.js 14.x
11+
- name: Use Node.js
1212
uses: actions/setup-node@v4
1313
with:
1414
node-version: "20.11.0"

.github/workflows/npm-publish.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3+
4+
name: Publish package to npm
5+
6+
on:
7+
repository_dispatch:
8+
types: [publish-new-version]
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Use Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: "20.11.0"
22+
- name: Install dependencies
23+
run: npm ci
24+
- name: Lint
25+
run: npm run lint
26+
- name: Run tests
27+
run: npm run test
28+
env:
29+
VITE_CLARIFAI_USER_ID: ${{ secrets.VITE_CLARIFAI_USER_ID }}
30+
VITE_CLARIFAI_PAT: ${{ secrets.VITE_CLARIFAI_PAT }}
31+
- name: Build
32+
run: npm run build
33+
- name: Publish to npm
34+
run: npm publish --access public
35+
env:
36+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

.github/workflows/release-please.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
14+
check_commit_message:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
patternMatch: ${{ steps.check_pattern.outputs.match }}
18+
isReleaseComplete: ${{ steps.check_pattern.outputs.release_complete }}
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Check for release pattern in commit message
24+
id: check_pattern
25+
run: |
26+
PATTERN="Release-As: [0-9]+\.[0-9]+\.[0-9]+|release [0-9]+\.[0-9]+\.[0-9]+"
27+
COMMIT_MESSAGE=$(git log --format=%B -n 1)
28+
echo "Commit Message: $COMMIT_MESSAGE"
29+
if [[ "$COMMIT_MESSAGE" =~ $PATTERN ]]; then
30+
echo "Pattern found. Proceeding with the job."
31+
echo "::set-output name=match::true"
32+
else
33+
echo "Pattern not found. Skipping subsequent steps."
34+
echo "::set-output name=match::false"
35+
fi
36+
PATTERN="release [0-9]+\.[0-9]+\.[0-9]+"
37+
COMMIT_MESSAGE=$(git log --format=%B -n 1)
38+
echo "Commit Message: $COMMIT_MESSAGE"
39+
if [[ "$COMMIT_MESSAGE" =~ $PATTERN ]]; then
40+
echo "Pattern found. Proceeding with the job."
41+
echo "::set-output name=release_complete::true"
42+
else
43+
echo "Pattern not found. Skipping subsequent steps."
44+
echo "::set-output name=release_complete::false"
45+
fi
46+
47+
release-please:
48+
needs: check_commit_message
49+
runs-on: ubuntu-latest
50+
if: needs.check_commit_message.outputs.patternMatch == 'true'
51+
steps:
52+
- uses: google-github-actions/release-please-action@v4
53+
with:
54+
release-type: node
55+
56+
trigger-publish-dispatch:
57+
name: "Trigger Publish Repository Dispatch Event"
58+
needs: [release-please, check_commit_message]
59+
runs-on: ubuntu-latest
60+
if: needs.check_commit_message.outputs.isReleaseComplete == 'true'
61+
steps:
62+
- name: Create Release Repository Dispatch Event
63+
id: create_release_dispatch
64+
uses: peter-evans/repository-dispatch@v3
65+
with:
66+
event-type: publish-new-version

0 commit comments

Comments
 (0)