Skip to content

refactor: migrate from Biome to oxfmt and oxlint for formatting and l… #7

refactor: migrate from Biome to oxfmt and oxlint for formatting and l…

refactor: migrate from Biome to oxfmt and oxlint for formatting and l… #7

Workflow file for this run

name: Release
on:
push:
branches:
- main
concurrency: release
permissions:
id-token: write
contents: write
pull-requests: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
changed_dirs: ${{ steps.tag.outputs.changed_dirs || '[]' }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
fetch-tags: true
- uses: pnpm/action-setup@d15e628ca66d93ee5f352c71671a7bc6a97af5c9 # v6.0.8
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: '.nvmrc'
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Check for pending changesets
id: check
run: |
changeset_files=$(find .changeset -name '*.md' ! -name 'README.md' 2>/dev/null || true)
if [ -z "$changeset_files" ]; then
echo "No pending changesets found. Skipping release."
echo "has_changesets=false" >> "$GITHUB_OUTPUT"
else
echo "Pending changesets found:"
echo "$changeset_files"
echo "has_changesets=true" >> "$GITHUB_OUTPUT"
fi
- name: Version packages
if: steps.check.outputs.has_changesets == 'true'
run: pnpm run version-packages
- name: Check for version changes
if: steps.check.outputs.has_changesets == 'true'
id: diff
run: |
if git diff --quiet; then
echo "No version changes produced. Skipping commit."
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit version bumps
if: steps.diff.outputs.has_changes == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Version Packages"
- name: Open Version Packages pull request
if: steps.diff.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BRANCH="changeset-release/version-packages"
git push origin HEAD:"refs/heads/${BRANCH}" --force
if gh pr list --base main --head "${BRANCH}" --state open --json number -q '.[0].number' | grep -q .; then
echo "Updated existing Version Packages pull request on branch ${BRANCH}"
else
gh pr create \
--base main \
--head "${BRANCH}" \
--title "Version Packages" \
--body "$(cat <<'EOF'
This PR was opened automatically by the Release workflow.
It applies pending changesets: version bumps in `package.json`, synced `codemod.yaml` versions, and changelog updates.
**After this PR is merged**, the Release workflow will create git tags and publish the affected codemods to the registry.
EOF
)"
fi
- name: Tag released versions
if: steps.check.outputs.has_changesets != 'true'
id: tag
run: bash scripts/tag-and-publish.sh
publish:
name: Publish ${{ matrix.dir }}
needs: release
if: needs.release.outputs.changed_dirs != '[]' && needs.release.outputs.changed_dirs != ''
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
dir: ${{ fromJson(needs.release.outputs.changed_dirs) }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: main
- uses: pnpm/action-setup@d15e628ca66d93ee5f352c71671a7bc6a97af5c9 # v6.0.8
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: '.nvmrc'
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Publish codemod
uses: codemod/publish-action@dd6c8dbc5ceb1a6146feba41481d88b43da50024 # v1
with:
path: ${{ matrix.dir }}