Skip to content

chore: increase jobs timeout #29

chore: increase jobs timeout

chore: increase jobs timeout #29

Workflow file for this run

name: Publish plugin models Package to npmjs
on:
push:
branches:
- main
paths:
- ".github/workflows/build.yml"
- "src/**"
- "*.json"
- "!src/package.json"
pull_request:
branches:
- main
jobs:
build-and-publish-plugins:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
token: ${{ secrets.PAT_SERVICE_ACCOUNT }}
- name: Install jq
uses: dcarbone/[email protected]
- name: "Auto Increase package Version"
if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
run: |
# Extract current version
current_version=$(jq -r '.version' src/package.json)
# Break the version into its components
major_version=$(echo $current_version | cut -d "." -f 1)
minor_version=$(echo $current_version | cut -d "." -f 2)
patch_version=$(echo $current_version | cut -d "." -f 3)
# Increment the patch version by one
new_patch_version=$((patch_version+1))
# Construct the new version
new_version="$major_version.$minor_version.$new_patch_version"
# Replace the old version with the new version in package.json
jq --arg version "$new_version" '.version = $version' src/package.json > /tmp/package.json && mv /tmp/package.json src/package.json
# Print the new version
echo "Updated package.json version to: $new_version"
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- run: npm install && npm run build
working-directory: ./src
- run: npm publish --access public
if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: ./src
- uses: gacts/purge-jsdelivr-cache@v1
if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
with:
url: |
https://cdn.jsdelivr.net/npm/@janhq/models@latest/dist/index.js
- name: "Commit new version to main and create tag"
if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
run: |
version=$(jq -r '.version' src/package.json)
git config --global user.email "[email protected]"
git config --global user.name "Service Account"
git add src/package.json
git commit -m "${GITHUB_REPOSITORY}: Update tag build $version"
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin HEAD:main
git tag -a models-$version -m "${GITHUB_REPOSITORY}: Update tag build $version for models"
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin models-$version