Skip to content

Commit

Permalink
ci: setup release pipeline (#5)
Browse files Browse the repository at this point in the history
Release-As: 0.0.1
  • Loading branch information
DaniAkash authored Apr 2, 2024
1 parent 2c9456b commit 5206bd8
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20.11.0"
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Publish package to npm

on:
repository_dispatch:
types: [publish-new-version]

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20.11.0"
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Run tests
run: npm run test
env:
VITE_CLARIFAI_USER_ID: ${{ secrets.VITE_CLARIFAI_USER_ID }}
VITE_CLARIFAI_PAT: ${{ secrets.VITE_CLARIFAI_PAT }}
- name: Build
run: npm run build
- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
66 changes: 66 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Release

on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:

check_commit_message:
runs-on: ubuntu-latest
outputs:
patternMatch: ${{ steps.check_pattern.outputs.match }}
isReleaseComplete: ${{ steps.check_pattern.outputs.release_complete }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check for release pattern in commit message
id: check_pattern
run: |
PATTERN="Release-As: [0-9]+\.[0-9]+\.[0-9]+|release [0-9]+\.[0-9]+\.[0-9]+"
COMMIT_MESSAGE=$(git log --format=%B -n 1)
echo "Commit Message: $COMMIT_MESSAGE"
if [[ "$COMMIT_MESSAGE" =~ $PATTERN ]]; then
echo "Pattern found. Proceeding with the job."
echo "::set-output name=match::true"
else
echo "Pattern not found. Skipping subsequent steps."
echo "::set-output name=match::false"
fi
PATTERN="release [0-9]+\.[0-9]+\.[0-9]+"
COMMIT_MESSAGE=$(git log --format=%B -n 1)
echo "Commit Message: $COMMIT_MESSAGE"
if [[ "$COMMIT_MESSAGE" =~ $PATTERN ]]; then
echo "Pattern found. Proceeding with the job."
echo "::set-output name=release_complete::true"
else
echo "Pattern not found. Skipping subsequent steps."
echo "::set-output name=release_complete::false"
fi
release-please:
needs: check_commit_message
runs-on: ubuntu-latest
if: needs.check_commit_message.outputs.patternMatch == 'true'
steps:
- uses: google-github-actions/release-please-action@v4
with:
release-type: node

trigger-publish-dispatch:
name: "Trigger Publish Repository Dispatch Event"
needs: [release-please, check_commit_message]
runs-on: ubuntu-latest
if: needs.check_commit_message.outputs.isReleaseComplete == 'true'
steps:
- name: Create Release Repository Dispatch Event
id: create_release_dispatch
uses: peter-evans/repository-dispatch@v3
with:
event-type: publish-new-version

0 comments on commit 5206bd8

Please sign in to comment.