Skip to content

Commit

Permalink
Merge pull request #412 from dojoengine/feat/release-update
Browse files Browse the repository at this point in the history
Feat/release update
  • Loading branch information
MartianGreed authored Mar 4, 2025
2 parents 6e90099 + a2411fd commit 4f97595
Showing 1 changed file with 92 additions and 10 deletions.
102 changes: 92 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
description: "Type of release (prerelease, prepatch, patch, minor, preminor, major)"
required: true
default: "patch"
dry_run:
description: "Dry run (no actual publishing or commits)"
required: false
default: false
type: boolean

jobs:
release:
Expand All @@ -20,6 +25,11 @@ jobs:
with:
version: 10.0.0

- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'pnpm'

- name: Configure Git
run: |
git config user.name "${{ github.actor }}"
Expand All @@ -36,15 +46,87 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: pnpm release
setupGitUser: false
title: "feat: prepare release"
commit: "feat: prepare release"
createGithubReleases: true
- name: Version packages
id: changesets-version
run: |
# Apply version bump based on release type
pnpm exec changeset version ${{ github.event.inputs.release_type }}
# Store the new version
NEW_VERSION=$(node -p "require('./package.json').version")
echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT
# If this is a dry run, revert the version changes
if [ "${{ github.event.inputs.dry_run }}" == "true" ]; then
echo "DRY RUN: Would version packages to ${NEW_VERSION}"
git checkout -- .
fi
- name: Build packages
run: pnpm build

- name: Publish to npm
if: ${{ github.event.inputs.dry_run != 'true' }}
run: pnpm publish --no-git-checks
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Dry run - Show npm publish
if: ${{ github.event.inputs.dry_run == 'true' }}
run: |
echo "DRY RUN: Would publish the following packages to npm:"
echo "Version: ${{ steps.changesets-version.outputs.new_version }}"
pnpm publish --dry-run
- name: Commit changes
if: ${{ github.event.inputs.dry_run != 'true' }}
run: |
git add .
git commit -m "chore: release v${{ steps.changesets-version.outputs.new_version }}" || echo "No changes to commit"
- name: Create and push tag
if: ${{ github.event.inputs.dry_run != 'true' }}
run: |
git tag v${{ steps.changesets-version.outputs.new_version }}
git push origin v${{ steps.changesets-version.outputs.new_version }}
git push origin main
- name: Dry run - Show git changes
if: ${{ github.event.inputs.dry_run == 'true' }}
run: |
echo "DRY RUN: Would commit changes with message: chore: release v${{ steps.changesets-version.outputs.new_version }}"
echo "DRY RUN: Would create and push tag: v${{ steps.changesets-version.outputs.new_version }}"
git status
- name: Generate release notes
id: generate-notes
run: |
pnpm exec changeset changelog
RELEASE_NOTES=$(cat CHANGELOG.md | sed -n -e '/^## /{n;:a;n;/^## /q;p;ba}' | tr -d '\n')
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# If this is a dry run, revert the changelog changes
if [ "${{ github.event.inputs.dry_run }}" == "true" ]; then
git checkout -- CHANGELOG.md
fi
- name: Create GitHub Release
if: ${{ github.event.inputs.dry_run != 'true' }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.changesets-version.outputs.new_version }}
release_name: Release v${{ steps.changesets-version.outputs.new_version }}
body: ${{ steps.generate-notes.outputs.release_notes }}
draft: false
prerelease: false

- name: Dry run - Show GitHub Release
if: ${{ github.event.inputs.dry_run == 'true' }}
run: |
echo "DRY RUN: Would create GitHub release with tag: v${{ steps.changesets-version.outputs.new_version }}"
echo "DRY RUN: Release notes would be:"
echo "${{ steps.generate-notes.outputs.release_notes }}"

0 comments on commit 4f97595

Please sign in to comment.