Skip to content

Commit

Permalink
lala
Browse files Browse the repository at this point in the history
  • Loading branch information
hathbanger committed Oct 12, 2024
1 parent 93e964b commit 3e039b4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 146 deletions.
189 changes: 43 additions & 146 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ on:
- main

jobs:
detect-changes-and-version:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v2
with:
node-version: 20
node-version: 16

- name: Setup pnpm
uses: pnpm/action-setup@v2
Expand All @@ -26,159 +26,56 @@ jobs:
- name: Install dependencies
run: pnpm install

# Check if lasereyes package has changed
- name: Check if lasereyes package changed
id: check_changes
id: lasereyes-changes
run: |
git diff --quiet HEAD^ HEAD -- packages/lasereyes || echo "changed=true" >> $GITHUB_ENV
- name: Exit pre-release mode if active
run: |
if pnpm changeset status | grep -q "pre mode"; then
pnpm changeset pre exit
changed="false"
if git diff --name-only HEAD^ HEAD | grep "packages/lasereyes"; then
changed="true"
fi
echo "changed=$changed" >> $GITHUB_ENV
# Check if already in pre-release mode
- name: Check pre-release mode
run: |
if pnpm changeset status --since dev | grep -q "pre mode"; then
echo "pre_mode=true" >> $GITHUB_ENV
else
echo "pre_mode=false" >> $GITHUB_ENV
fi
# Automatically add a changeset if changes are detected
# Add a changeset if lasereyes package changed
- name: Add Changeset if lasereyes package changed
if: env.changed == 'true'
run: |
if [ "$changed" = "true" ]; then
pnpm changeset add --empty --force --message "chore: auto-bump lasereyes version"
fi
# Enter pre-release mode for RC if on dev and not already in pre mode
- name: Run Changesets pre-release mode for RC
if: github.ref == 'refs/heads/dev' && env.pre_mode == 'false'
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
pnpm changeset add --empty --force --message "chore: auto-bump lasereyes version"
- 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
if: env.pre_mode == 'true'
# Check if already in pre-release mode on dev
- name: Check pre-release mode
run: |
if [ "$changed" = "true" ]; then
if pnpm changeset status | grep -q "pre mode"; then
echo "Already in pre-release mode, exiting pre mode..."
pnpm changeset pre exit
fi
- name: Run Changesets version for stable
run: |
if [ "$changed" = "true" ]; then
pnpm changeset version
fi
# Run Changesets pre-release mode for RC
- name: Run Changesets pre-release mode for RC
if: github.ref == 'refs/heads/dev' && env.changed == 'true'
run: pnpm changeset pre enter rc

- name: Commit version bumps and changelog for stable
# Commit version bumps and changelog
- name: Commit version bumps and changelog
if: github.ref == 'refs/heads/dev' && env.changed == 'true'
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
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
# Run Changesets version for main
- name: Run Changesets version for main
if: github.ref == 'refs/heads/main' && env.changed == 'true'
run: pnpm changeset version

# Commit version bumps and changelog for main
- name: Commit version bumps and changelog for main
if: github.ref == 'refs/heads/main' && env.changed == 'true'
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 }}
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 "Release version bump for lasereyes"
git push origin main
1 change: 1 addition & 0 deletions packages/lasereyes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ If you find Lasereyes useful or use it for work, please consider [sponsoring Las
[Sponsor Laser Eyes](https://github.com/sponsors/omnisat)



0 comments on commit 3e039b4

Please sign in to comment.