Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 47 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: pnpm/action-setup@v4

- name: Prepare Node.js
uses: actions/setup-node@v6.0.0
uses: actions/setup-node@v6
with:
node-version-file: .node-version
cache: pnpm
Expand All @@ -35,75 +35,66 @@ jobs:
- name: Lint
run: pnpm run lint

check-renovate-changefile:
if: startsWith(github.event.pull_request.head.ref, 'renovate/') && github.base_ref == github.event.repository.default_branch
check-version-plan:
needs: install
if: github.base_ref == github.event.repository.default_branch && github.head_ref != 'release' && !startsWith(github.head_ref, 'renovate/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.RENOVATE_AUTO_BEACHBALL_CHANGEFILE_TOKEN }}
fetch-depth: 0

- name: Prepare pnpm
uses: pnpm/action-setup@v4

# Install dependencies (example using pnpm)
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v5
- name: Prepare Node.js
uses: actions/setup-node@v6
with:
node-version-file: .node-version
cache: pnpm
- run: pnpm install

- name: Check and generate changefile for Renovate
# Pin to the last commit on main before this action was removed (replaced by renovate-auto-version-plan)
uses: RightCapitalHQ/frontend-style-guide/.github/actions/renovate-auto-beachball-changefile@e7e6cdd89b0a5e56bb7b1b5280aae241d9e4e848
- name: Install dependencies
run: pnpm install

check-beachball-changefile:
if: github.base_ref == github.event.repository.default_branch
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6.0.0
with:
node-version-file: .node-version
cache: pnpm
- run: pnpm install
- name: Set SHAs for Nx
uses: nrwl/nx-set-shas@v4

- name: Check version plan
run: pnpm exec nx release plan:check

- name: Check
run: pnpm exec beachball check
check-renovate-version-plan:
needs: install
if: startsWith(github.event.pull_request.head.ref, 'renovate/') && github.base_ref == github.event.repository.default_branch
uses: RightCapitalHQ/actions/.github/workflows/nx-release-auto-plan.yml@nx-release-auto-plan/v0.4.2
secrets: inherit

build:
if: ${{ always() && !failure() && !cancelled() }}
needs: check-beachball-changefile
prerelease:
if: >-
!failure() && !cancelled()
&& github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.full_name == 'RightCapitalHQ/php-parser'
&& github.base_ref == github.event.repository.default_branch
&& github.head_ref != 'release'
needs: [install, check-version-plan, check-renovate-version-plan]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6.0.0
- uses: actions/create-github-app-token@v3
id: app-token
with:
node-version-file: .node-version
cache: pnpm
- run: pnpm install

- name: Build
run: pnpm run build

- name: Publish (development)
if: github.repository == 'RightCapitalHQ/php-parser' && github.base_ref == github.event.repository.default_branch
app-id: ${{ secrets.RC_BOT_APP_ID }}
private-key: ${{ secrets.RC_BOT_PRIVATE_KEY }}
permission-actions: write
- name: Trigger prerelease workflow
env:
HEAD_REF: ${{ github.head_ref }}
run: |
preid="${HEAD_REF//\//-}".${{ github.run_number }}.${{ github.run_attempt }}
npm --no-git-tag-version version prerelease --preid="${preid}"
pnpm publish --no-git-checks --access public --tag development

- name: Publish (main)
if: github.repository == 'RightCapitalHQ/php-parser' && github.ref_name == github.event.repository.default_branch
GH_TOKEN: ${{ steps.app-token.outputs.token }}
BRANCH_NAME: ${{ github.head_ref }}
RUN_NUMBER: ${{ github.run_number }}
RUN_ATTEMPT: ${{ github.run_attempt }}
run: |
git config --local user.email "npm-publisher@rightcapital.com"
git config --local user.name "GitHub Actions[bot]"
pnpm beachball publish --access public --yes -m 'chore(release): applying package updates'
gh workflow run release.yml \
--repo "$GITHUB_REPOSITORY" \
-f prerelease=true \
-f "branch_name=${BRANCH_NAME}" \
-f "run_number=${RUN_NUMBER}" \
-f "run_attempt=${RUN_ATTEMPT}"
15 changes: 15 additions & 0 deletions .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Release PR

on:
push:
branches: [main]
workflow_dispatch:

jobs:
create-release-pr:
uses: RightCapitalHQ/actions/.github/workflows/nx-release-pr.yml@nx-release-pr/v0.4.2
with:
release-branch: release
base: main
pr-title: 'chore(release): release packages'
secrets: inherit
68 changes: 68 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Release

on:
pull_request:
types: [closed]
branches: [main]

workflow_dispatch:
inputs:
prerelease:
required: true
type: boolean
branch_name:
required: true
type: string
run_number:
required: true
type: string
run_attempt:
required: true
type: string

jobs:
release:
if: >-
github.event_name == 'pull_request'
&& github.event.pull_request.merged == true
&& github.event.pull_request.head.ref == 'release'
uses: RightCapitalHQ/actions/.github/workflows/nx-release.yml@nx-release/v0.4.2
with:
publish: true
secrets: inherit

prerelease:
if: inputs.prerelease
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.branch_name }}
persist-credentials: false

- name: Setup PHP with Composer
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: composer

- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version-file: .node-version
cache: pnpm
- run: pnpm install

- name: Publish prerelease (development)
env:
BRANCH_NAME: ${{ inputs.branch_name }}
RUN_NUMBER: ${{ inputs.run_number }}
RUN_ATTEMPT: ${{ inputs.run_attempt }}
NPM_CONFIG_PROVENANCE: true
run: |
preid="${BRANCH_NAME//\//-}".${RUN_NUMBER}.${RUN_ATTEMPT}
npm --no-git-tag-version version prerelease --preid="${preid}"
pnpm publish --no-git-checks --access public --tag development
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ logs
*.log
npm-debug.log*
lerna-debug.log*

# nx
/.nx/cache
/.nx/workspace-data
!/.nx/version-plans/
5 changes: 5 additions & 0 deletions .nx/version-plans/migrate-to-nx-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rightcapital/php-parser": patch
---

Migrate from beachball to Nx Release workflow.
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ src/php-parser/types/node
src/php-parser/types/types.ts
pnpm-lock.yaml
composer.lock
CHANGELOG.md
CHANGELOG.md
.nx/version-plans/
Loading
Loading