Skip to content

Fix sync queue and dirty-day handling #91

Fix sync queue and dirty-day handling

Fix sync queue and dirty-day handling #91

Workflow file for this run

name: Changeset
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
jobs:
changeset:
name: πŸ“¦ Version Packages
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: πŸ—οΈ Checkout
uses: actions/checkout@v4
with:
# Use PAT to allow commits to trigger workflows
token: ${{ secrets.GH_PAT }}
fetch-depth: 0
- name: πŸ“¦ Setup Node
uses: actions/setup-node@v4
with:
node-version: 24.x
- name: πŸ“‚ Get yarn cache directory
id: yarn-cache
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: πŸ’Ύ Cache yarn downloads
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-cache-
- name: πŸ’Ύ Cache node_modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: πŸ“₯ Install dependencies
run: yarn install --immutable
- name: πŸ”„ Create Release PR or Publish
id: changesets
uses: changesets/action@v1
with:
version: yarn changeset:version
commit: "chore: version packages"
title: "chore: version packages"
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
- name: πŸ” Check if version PR was merged
id: check-release
run: |
# Check if there are no changesets and no open version PR
# This means the version PR was just merged
CHANGESET_COUNT=$(ls .changeset/*.md 2>/dev/null | grep -v README.md | wc -l || echo "0")
echo "Changeset count: $CHANGESET_COUNT"
if [ "$CHANGESET_COUNT" -eq "0" ] && [ "${{ steps.changesets.outputs.hasChangesets }}" != "true" ]; then
# Check if current version has a tag
VERSION=$(node -p "require('./package.json').version")
TAG="v$VERSION"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists"
echo "should_release=false" >> $GITHUB_OUTPUT
else
echo "No tag for $TAG, should release"
echo "should_release=true" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
fi
else
echo "Changesets pending or PR created, skipping release"
echo "should_release=false" >> $GITHUB_OUTPUT
fi
- name: 🏷️ Push tag
id: push-tag
if: steps.check-release.outputs.should_release == 'true'
run: |
TAG="${{ steps.check-release.outputs.tag }}"
echo "Creating and pushing tag: $TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT
# Get user info from PAT
USER_DATA=$(curl -s -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/user)
USER_NAME=$(echo "$USER_DATA" | jq -r '.name // .login')
USER_ID=$(echo "$USER_DATA" | jq -r '.id')
USER_LOGIN=$(echo "$USER_DATA" | jq -r '.login')
git config user.name "$USER_NAME"
git config user.email "[email protected]"
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}