Skip to content

fix: Improve release #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
- uses: oven-sh/setup-bun@v1
- uses: pnpm/action-setup@v3
with:
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ jobs:
run: pnpm run build

- name: Tag and Publish Packages
id: tag_publish
run: |
npx lerna version ${{ github.event.inputs.release_type }} --conventional-commits --yes --no-private --force-publish
npx lerna publish from-git --yes --dist-tag ${{ github.event.inputs.release_type == 'preminor' && 'next' || 'latest' }}

Comment on lines +43 to 47
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

⚠️ Potential issue

Keep --force-publish flag and add explicit output capture

The --force-publish flag is necessary due to the extensive interdependencies between packages. The packages form a complex dependency graph where:

  • sdk depends on core, create-burner, and torii-client
  • react depends on state, torii-client, and utils
  • state depends on torii-client
  • Multiple packages depend on torii-client

Only add the output capture modification:

  id: tag_publish
  run: |
+     echo "TAG=$(npx lerna version ${{ github.event.inputs.release_type }} --conventional-commits --yes --no-private --force-publish | tail -n 1)" >> $GITHUB_OUTPUT
-     npx lerna version ${{ github.event.inputs.release_type }} --conventional-commits --yes --no-private --force-publish
      npx lerna publish from-git --yes --dist-tag ${{ github.event.inputs.release_type == 'preminor' && 'next' || 'latest' }}
🔗 Analysis chain

Add explicit output capture for the tag version

The step ID tag_publish suggests this step should output the tag version, but there's no explicit output capture. This could cause the subsequent GitHub Release step to fail.

Apply this modification:

  id: tag_publish
  run: |
+     echo "TAG=$(npx lerna version ${{ github.event.inputs.release_type }} --conventional-commits --yes --no-private --force-publish | tail -n 1)" >> $GITHUB_OUTPUT
-     npx lerna version ${{ github.event.inputs.release_type }} --conventional-commits --yes --no-private --force-publish
      npx lerna publish from-git --yes --dist-tag ${{ github.event.inputs.release_type == 'preminor' && 'next' || 'latest' }}

Also, consider removing the --force-publish flag unless absolutely necessary, as it bypasses version checks and could lead to unintended publications.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if force-publish is really needed by looking for dependencies between packages
rg -l "workspace:.*" packages/*/package.json

Length of output: 510


Script:

#!/bin/bash
# Let's check the actual workspace dependencies in these packages
for file in packages/torii-client/package.json packages/state/package.json packages/sdk/package.json packages/create-burner/package.json packages/react/package.json packages/core/package.json; do
    echo "=== $file ==="
    cat "$file" | jq '.dependencies,.devDependencies' | grep -A1 "workspace:"
done

Length of output: 2793

- name: Generate Changelog
- name: Generate Changelog with standard-version
run: |
npx lerna-changelog > CHANGELOG.md
npx standard-version --tag-prefix v --commit-all

- name: Commit and Push Changelog
run: |
Expand All @@ -55,3 +56,14 @@ jobs:
git push origin HEAD:${{ github.ref }}
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}

- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_publish.outputs.TAG }}
release_name: Release ${{ steps.tag_publish.outputs.TAG }}
body_path: CHANGELOG.md
draft: false
prerelease: ${{ contains(github.event.inputs.release_type, 'pre') }}
Comment on lines +60 to +69
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Replace deprecated action and improve release content

The actions/create-release@v1 action is deprecated. Additionally, using the entire CHANGELOG.md file might include historical entries irrelevant to this release.

Replace with the newer softprops/action-gh-release action:

- name: Create GitHub Release
- uses: actions/create-release@v1
- env:
-   GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
-   tag_name: ${{ steps.tag_publish.outputs.TAG }}
-   release_name: Release ${{ steps.tag_publish.outputs.TAG }}
-   body_path: CHANGELOG.md
-   draft: false
-   prerelease: ${{ contains(github.event.inputs.release_type, 'pre') }}
+ name: Create GitHub Release
+ uses: softprops/action-gh-release@v1
+ with:
+   tag_name: ${{ steps.tag_publish.outputs.TAG }}
+   name: Release ${{ steps.tag_publish.outputs.TAG }}
+   body: |
+     # Release Notes
+     $(cat CHANGELOG.md | sed -n "/^## \[${{ steps.tag_publish.outputs.TAG }}/,/^## \[/p" | sed '$d')
+   draft: false
+   prerelease: ${{ contains(github.event.inputs.release_type, 'pre') }}
+   token: ${{ secrets.GITHUB_TOKEN }}

This change:

  1. Uses a maintained action
  2. Extracts only the relevant section from CHANGELOG.md
  3. Adds a better formatted release body
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_publish.outputs.TAG }}
release_name: Release ${{ steps.tag_publish.outputs.TAG }}
body_path: CHANGELOG.md
draft: false
prerelease: ${{ contains(github.event.inputs.release_type, 'pre') }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag_publish.outputs.TAG }}
name: Release ${{ steps.tag_publish.outputs.TAG }}
body: |
# Release Notes
$(cat CHANGELOG.md | sed -n "/^## \[${{ steps.tag_publish.outputs.TAG }}/,/^## \[/p" | sed '$d')
draft: false
prerelease: ${{ contains(github.event.inputs.release_type, 'pre') }}
token: ${{ secrets.GITHUB_TOKEN }}

Loading