87 lines
2.5 KiB
YAML
87 lines
2.5 KiB
YAML
name: Release
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "0 8 * * 1" # Mondays 08:00 UTC = 10:00 Madrid (CEST) / 09:00 (CET)
|
|
workflow_dispatch:
|
|
inputs:
|
|
increment:
|
|
description: "Version increment"
|
|
required: true
|
|
default: patch
|
|
type: choice
|
|
options:
|
|
- patch
|
|
- minor
|
|
- major
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout main
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: main
|
|
fetch-depth: 0
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Configure git
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
|
|
- name: Check for releasable commits
|
|
id: guard
|
|
run: |
|
|
LAST=$(git describe --tags --abbrev=0)
|
|
if [ -z "$(git log "$LAST"..HEAD --oneline)" ]; then
|
|
echo "No commits since $LAST; skipping release."
|
|
echo "skip=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "skip=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Create release branch
|
|
id: branch
|
|
if: steps.guard.outputs.skip != 'true'
|
|
run: |
|
|
BRANCH="release/run-${{ github.run_id }}"
|
|
git checkout -b "$BRANCH"
|
|
echo "name=$BRANCH" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Run release-it
|
|
if: steps.guard.outputs.skip != 'true'
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: npx release-it "${{ inputs.increment || 'patch' }}" --ci
|
|
|
|
- name: Read new version
|
|
id: version
|
|
if: steps.guard.outputs.skip != 'true'
|
|
run: echo "value=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Open pull request
|
|
if: steps.guard.outputs.skip != 'true'
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
gh pr create \
|
|
--base main \
|
|
--head "${{ steps.branch.outputs.name }}" \
|
|
--title "chore: release v${{ steps.version.outputs.value }}" \
|
|
--body "Automated release PR for **v${{ steps.version.outputs.value }}**.\n\nTag \`v${{ steps.version.outputs.value }}\` and the GitHub release have already been published. Merge this PR to land the version bump and CHANGELOG on \`main\`."
|