diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 09bf9455..7337d6e5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,18 +6,12 @@ on: - dev - main -permissions: - contents: write # Grants write permissions to push commits - jobs: - changeset-rc-version: + detect-changes-and-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 @@ -32,47 +26,32 @@ jobs: - 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' + id: check_changes 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 - - name: Check if any files were changed + 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 + if: env.changed == 'true' run: | - git status - git diff + pnpm dlx changeset add --empty --force --commit \ + --message "chore: auto-bump lasereyes version" - # Enter pre-release mode and version bump for lasereyes package + # Enter pre-release mode for RC if on dev - name: Run Changesets pre-release mode for RC - if: steps.lasereyes-changes.outputs.changed == 'true' + if: github.ref == 'refs/heads/dev' && env.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 }} + pnpm dlx @changesets/cli pre enter rc + pnpm dlx @changesets/cli version + # Commit version bump - name: Commit version bumps and changelog + if: github.ref == 'refs/heads/dev' && env.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 .changeset/pre.json + git add . git commit -m "RC version bump for lasereyes" git push origin dev env: @@ -80,42 +59,32 @@ jobs: publish-rc-release: runs-on: ubuntu-latest - needs: changeset-rc-version - if: needs.changeset-rc-version.outputs.changed == 'true' + needs: detect-changes-and-version + if: github.ref == 'refs/heads/dev' && env.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" + run: pnpm publish --tag rc --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} changeset-stable-version: runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' && env.changed == 'true' 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 @@ -130,21 +99,18 @@ jobs: - name: Install dependencies run: pnpm install - # Exit pre-release mode - - name: Exit RC mode + - name: Exit pre-release mode run: pnpm dlx @changesets/cli pre exit - # Run Changesets version to bump versions and generate changelogs for stable release - - name: Run Changesets version + - name: Run Changesets version for stable run: pnpm dlx @changesets/cli version - # Commit the stable version bump and changelog - - name: Commit version bumps and changelog + - name: Commit version bumps and changelog for stable 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 commit -m "Stable version bump for lasereyes" git push origin main env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -152,33 +118,24 @@ jobs: publish-stable-release: runs-on: ubuntu-latest needs: changeset-stable-version - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' && env.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 the stable version of lasereyes to npm - name: Publish stable release to npm - run: pnpm publish --access public --filter "lasereyes" + run: pnpm publish --access public 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: diff --git a/packages/lasereyes/README.md b/packages/lasereyes/README.md index 05285778..d80ff557 100644 --- a/packages/lasereyes/README.md +++ b/packages/lasereyes/README.md @@ -34,8 +34,6 @@ For help, discussion about best practices, or any other conversation that would ## Contributing - - Contributions to Lasereyes are greatly appreciated! If you're interested in contributing to Lasereyes, please read the [Contributing Guide](https://wagmi.sh/dev/contributing) **before submitting a pull request**. ## Sponsors