Merge pull request #41 from omnisat/hath #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- dev | |
- main | |
jobs: | |
detect-changes-and-version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8.6.6 | |
- name: Install dependencies | |
run: pnpm install | |
- name: Check if lasereyes package changed | |
id: check_changes | |
run: | | |
git diff --quiet HEAD^ HEAD -- packages/lasereyes || echo "changed=true" >> $GITHUB_ENV | |
# Automatically add a changeset if changes are detected | |
- name: Add Changeset if lasereyes package changed | |
run: | | |
if [ "$changed" = "true" ]; then | |
pnpm changeset add --empty --force --commit \ | |
--message "chore: auto-bump lasereyes version" | |
fi | |
# Enter pre-release mode for RC if on dev | |
- name: Run Changesets pre-release mode for RC | |
if: github.ref == 'refs/heads/dev' | |
run: | | |
if [ "$changed" = "true" ]; then | |
pnpm changeset pre enter rc | |
pnpm changeset version | |
fi | |
# Commit version bump | |
- name: Commit version bumps and changelog | |
if: github.ref == 'refs/heads/dev' | |
run: | | |
if [ "$changed" = "true" ]; then | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "RC version bump for lasereyes" | |
git push origin dev | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish-rc-release: | |
runs-on: ubuntu-latest | |
needs: detect-changes-and-version | |
if: github.ref == 'refs/heads/dev' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install dependencies | |
run: pnpm install | |
- name: Publish RC to npm | |
run: | | |
if [ "$changed" = "true" ]; then | |
pnpm publish --tag rc --access public | |
fi | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
changeset-stable-version: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
needs: publish-rc-release | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8.6.6 | |
- name: Install dependencies | |
run: pnpm install | |
- name: Exit pre-release mode | |
run: | | |
if [ "$changed" = "true" ]; then | |
pnpm changeset pre exit | |
fi | |
- name: Run Changesets version for stable | |
run: | | |
if [ "$changed" = "true" ]; then | |
pnpm changeset version | |
fi | |
- name: Commit version bumps and changelog for stable | |
run: | | |
if [ "$changed" = "true" ]; then | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "Stable version bump for lasereyes" | |
git push origin main | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish-stable-release: | |
runs-on: ubuntu-latest | |
needs: changeset-stable-version | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install dependencies | |
run: pnpm install | |
- name: Publish stable release to npm | |
run: | | |
if [ "$changed" = "true" ]; then | |
pnpm publish --access public | |
fi | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Create GitHub Release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ github.sha }} | |
release_name: "Stable Release ${{ github.sha }}" | |
body_path: releases/main_summary_notes_$(date +'%Y-%m-%d').md | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |