diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..898b82c --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,42 @@ +name: NPM Publish + +on: + pull_request: + types: [closed] + branches: + - main + +jobs: + publish: + # Only run if the PR was merged (not just closed) and has the version-bump label + if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'version-bump') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: main # Ensure we're on main branch + + - 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: Publish to NPM + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7eba9a6..6b52a24 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,4 @@ -name: Publish Package +name: Version Bump on: push: @@ -6,12 +6,13 @@ on: - main jobs: - publish: + version-bump: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # Required for version bumping + ssh-key: ${{ secrets.DEPLOY_KEY }} # Use deploy key to bypass branch protection - name: Setup Git run: | @@ -38,34 +39,14 @@ jobs: - name: Build run: bun run build - - name: Bump version and create PR + - name: Bump version and push 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 + # Use SSH URL for the repository + git remote set-url origin git@github.com:${GITHUB_REPOSITORY}.git # 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 + # Push directly to main + git push origin HEAD:main --tags - name: Publish to NPM run: npm publish diff --git a/package.json b/package.json index 3c82f9a..1e9534f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onkernel/create-kernel-app", - "version": "0.1.7", + "version": "0.1.8", "description": "Create Kernel sample applications", "main": "dist/index.js", "type": "module",