100 lines
3.4 KiB
YAML
100 lines
3.4 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
jobs:
|
|
release:
|
|
name: Release
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
|
|
- name: Install dependencies
|
|
run: bun install
|
|
|
|
- name: Create Release Pull Request or Tag
|
|
id: changesets
|
|
uses: changesets/action@v1
|
|
with:
|
|
version: bun run version
|
|
publish: echo "No publish step - plugins are consumed from git"
|
|
title: "chore: version packages"
|
|
commit: "chore: version packages"
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Update PR title with versions
|
|
# Runs when changesets action creates/updates a version PR (has pending changesets)
|
|
if: steps.changesets.outputs.pullRequestNumber
|
|
run: |
|
|
set -e
|
|
# Build descriptive title by comparing versions against main
|
|
VERSIONS=""
|
|
for plugin in outfitter but gt cli-dev outfitter-stack; do
|
|
PKG_PATH="plugins/$plugin/package.json"
|
|
if [ -f "$PKG_PATH" ]; then
|
|
NEW_VERSION=$(jq -r .version "$PKG_PATH")
|
|
# Get version from main branch (may not exist for new plugins)
|
|
OLD_VERSION=$(git show origin/main:"$PKG_PATH" 2>/dev/null | jq -r '.version // "0.0.0"' 2>/dev/null || echo "0.0.0")
|
|
|
|
# Include if version changed
|
|
if [ "$NEW_VERSION" != "$OLD_VERSION" ]; then
|
|
if [ -n "$VERSIONS" ]; then
|
|
VERSIONS="$VERSIONS, "
|
|
fi
|
|
VERSIONS="${VERSIONS}${plugin}@${NEW_VERSION}"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
if [ -n "$VERSIONS" ]; then
|
|
TITLE="chore: release $VERSIONS"
|
|
gh pr edit ${{ steps.changesets.outputs.pullRequestNumber }} --title "$TITLE"
|
|
echo "Updated PR title to: $TITLE"
|
|
fi
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Label and auto-merge version PR
|
|
if: steps.changesets.outputs.pullRequestNumber
|
|
run: |
|
|
set -e
|
|
# Label may fail if it doesn't exist yet - continue anyway
|
|
gh pr edit ${{ steps.changesets.outputs.pullRequestNumber }} --add-label "release:publish" || true
|
|
gh pr merge ${{ steps.changesets.outputs.pullRequestNumber }} --auto --squash
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Create git tags
|
|
# Runs when no pending changesets (version PR was merged, versions already bumped)
|
|
if: steps.changesets.outputs.hasChangesets == 'false'
|
|
run: |
|
|
set -e
|
|
# After version PR is merged, create tags for each plugin
|
|
for plugin in outfitter but gt cli-dev outfitter-stack; do
|
|
PKG_PATH="plugins/$plugin/package.json"
|
|
if [ -f "$PKG_PATH" ]; then
|
|
VERSION=$(jq -r .version "$PKG_PATH")
|
|
TAG="${plugin}@${VERSION}"
|
|
|
|
# Check if tag already exists
|
|
if ! git rev-parse "$TAG" >/dev/null 2>&1; then
|
|
echo "Creating tag: $TAG"
|
|
git tag "$TAG"
|
|
git push origin "$TAG"
|
|
fi
|
|
fi
|
|
done
|