Skip to content

Merge pull request #36 from omnisat/hath #36

Merge pull request #36 from omnisat/hath

Merge pull request #36 from omnisat/hath #36

Workflow file for this run

name: Release
on:
push:
branches:
- dev
- main
permissions:
contents: write # Grants write permissions to push commits
jobs:
changeset-rc-version:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- 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
# Check if lasereyes package has changed
- name: Check if lasereyes package changed
id: lasereyes-changes
run: |
if git diff --name-only HEAD^1 HEAD | grep -q "packages/lasereyes/"; then
echo "Lasereyes package changed."
echo "::set-output name=changed::true"
else
echo "Lasereyes package did not change."
echo "::set-output name=changed::false"
fi
# Check if already in pre-release mode, and exit if necessary
- name: Exit pre-release mode if active
if: steps.lasereyes-changes.outputs.changed == 'true'
run: |
if [ -f ".changeset/pre.json" ]; then
echo "Exiting pre-release mode"
pnpm dlx @changesets/cli pre exit
else
echo "Not in pre-release mode"
fi
# Enter pre-release mode and version bump for lasereyes package
- name: Run Changesets pre-release mode for RC
if: steps.lasereyes-changes.outputs.changed == 'true'
run: |
pnpm dlx @changesets/cli pre enter rc # Enter RC mode
pnpm dlx @changesets/cli version # Bump RC version for lasereyes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Commit version bumps and changelog
- name: Commit version bumps and changelog
if: steps.lasereyes-changes.outputs.changed == 'true'
run: |
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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-rc-release:
runs-on: ubuntu-latest
needs: changeset-rc-version
if: needs.changeset-rc-version.outputs.changed == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- 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
# Publish only the lasereyes RC version to npm
- name: Publish RC to npm
run: pnpm publish --tag rc --access public --filter "lasereyes"
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
with:
fetch-depth: 0
- 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
# Exit pre-release mode
- name: Exit RC mode
run: pnpm dlx @changesets/cli pre exit
# Run Changesets version to bump versions and generate changelogs for stable release
- name: Run Changesets version
run: pnpm dlx @changesets/cli version
# Commit the stable version bump and changelog
- name: Commit version bumps and changelog
run: |
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"
git push origin main
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
with:
fetch-depth: 0
- 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
# Publish the stable version of lasereyes to npm
- name: Publish stable release to npm
run: pnpm publish --access public --filter "lasereyes"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Create a GitHub Release with the summarized release notes
- 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 }}