Skip to content

gh action

gh action #6

Workflow file for this run

name: Publish Package
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for version bumping
- name: Setup Git
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'github-actions@github.com'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Run linting
run: bun run lint
- name: Build
run: bun run build
- name: Bump version and create PR
run: |
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
# Create a new branch for the version bump
BRANCH_NAME="chore/bump-version-$(date +%s)"
git checkout -b $BRANCH_NAME
# Bump version
npm version patch -m "chore: bump version to %s [skip ci]"
# Push the new branch
git push origin $BRANCH_NAME
# Create PR using GitHub CLI
gh pr create \
--title "chore: bump version" \
--body "Automated version bump" \
--base main \
--head $BRANCH_NAME
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_CLI_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup GitHub CLI
run: |
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}