-
Notifications
You must be signed in to change notification settings - Fork 321
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
feat: add auto publish workflow #1005
base: refactor/develop
Are you sure you want to change the base?
feat: add auto publish workflow #1005
Conversation
WalkthroughA new GitHub Actions workflow Changes
Suggested labels
Suggested reviewers
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Nitpick comments (1)
.github/workflows/Release.yml (1)
1-55
: Consider environment-specific workflow configurationsFor a more robust release process, consider:
- Adding environment-specific configurations (e.g., different registries for staging/production)
- Implementing release notes generation
- Adding post-publish verification steps
Example implementation:
# .github/workflows/Release.yml env: RELEASE_ENV: ${{ startsWith(github.ref, 'refs/tags/v') && 'production' || 'staging' }} # Then use conditions like: if: env.RELEASE_ENV == 'production'Would you like me to provide a complete implementation of these improvements?
🧰 Tools
🪛 actionlint (1.7.4)
40-40: shellcheck reported issue in this script: SC1009:info:2:1: The mentioned syntax error was in this if expression
(shellcheck)
40-40: shellcheck reported issue in this script: SC1035:error:2:4: You need a space after the [[ and before the ]]
(shellcheck)
40-40: shellcheck reported issue in this script: SC1073:error:2:4: Couldn't parse this test expression. Fix to allow more checks
(shellcheck)
40-40: shellcheck reported issue in this script: SC1020:error:2:30: You need a space before the ]]
(shellcheck)
40-40: shellcheck reported issue in this script: SC1072:error:2:30: Missing space before ]. Fix any mentioned problems and try again
(shellcheck)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/Release.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/Release.yml
40-40: shellcheck reported issue in this script: SC1009:info:2:1: The mentioned syntax error was in this if expression
(shellcheck)
40-40: shellcheck reported issue in this script: SC1035:error:2:4: You need a space after the [[ and before the ]]
(shellcheck)
40-40: shellcheck reported issue in this script: SC1073:error:2:4: Couldn't parse this test expression. Fix to allow more checks
(shellcheck)
40-40: shellcheck reported issue in this script: SC1020:error:2:30: You need a space before the ]]
(shellcheck)
40-40: shellcheck reported issue in this script: SC1072:error:2:30: Missing space before ]. Fix any mentioned problems and try again
(shellcheck)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: push-check
🔇 Additional comments (1)
.github/workflows/Release.yml (1)
16-34
: LGTM! Well-configured setup stepsThe setup steps are using the latest action versions and properly configured caching for optimal performance.
.github/workflows/Release.yml
Outdated
jobs: | ||
release: | ||
if: github.repository == '@opentiny/tiny-engine' | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
id-token: write | ||
steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add concurrency control to prevent parallel releases
Consider adding concurrency control to prevent multiple release workflows from running simultaneously, which could lead to race conditions.
jobs:
release:
+ concurrency: release-${{ github.ref }}
if: github.repository == 'opentiny/tiny-engine'
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
📝 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.
jobs: | |
release: | |
if: github.repository == '@opentiny/tiny-engine' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
jobs: | |
release: | |
concurrency: release-${{ github.ref }} | |
if: github.repository == '@opentiny/tiny-engine' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
steps: |
- name: Run Build | ||
run: pnpm run build:plugin && pnpm run build:alpha > build-alpha.log 2>&1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve build step error handling and logging
The build step has two potential improvements:
- The second build command will run even if the first fails
- The build log should be saved as an artifact for debugging
- name: Run Build
- run: pnpm run build:plugin && pnpm run build:alpha > build-alpha.log 2>&1
+ run: |
+ pnpm run build:plugin
+ pnpm run build:alpha > build-alpha.log 2>&1
+
+ - name: Upload build logs
+ if: always()
+ uses: actions/upload-artifact@v3
+ with:
+ name: build-logs
+ path: build-alpha.log
📝 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.
- name: Run Build | |
run: pnpm run build:plugin && pnpm run build:alpha > build-alpha.log 2>&1 | |
- name: Run Build | |
run: | | |
pnpm run build:plugin | |
pnpm run build:alpha > build-alpha.log 2>&1 | |
- name: Upload build logs | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-logs | |
path: build-alpha.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.github/workflows/Release.yml (2)
40-45
: Configure artifact retention periodConsider setting a retention period for build logs to manage storage:
- name: Upload build logs uses: actions/upload-artifact@v4 with: name: build-alpha-log path: build-alpha.log + retention-days: 30
76-79
: Add error handling for npm publishConsider adding error handling and retries for the npm publish command:
- name: Publish package to npm - run: pnpm lerna publish from-package --dist-tag ${{steps.parse_tag.outputs.dist_tag}} --yes + run: | + n=0 + until [ $n -ge 3 ]; do + pnpm lerna publish from-package --dist-tag ${{steps.parse_tag.outputs.dist_tag}} --yes && break + n=$((n+1)) + echo "Retry $n of 3" + sleep 15 + done env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + NPM_CONFIG_PROVENANCE: trueAlso added NPM provenance setting to enhance supply chain security.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/Release.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/Release.yml
48-48: shellcheck reported issue in this script: SC2086:info:3:28: Double quote to prevent globbing and word splitting
(shellcheck)
48-48: shellcheck reported issue in this script: SC2086:info:5:27: Double quote to prevent globbing and word splitting
(shellcheck)
48-48: shellcheck reported issue in this script: SC2086:info:7:25: Double quote to prevent globbing and word splitting
(shellcheck)
48-48: shellcheck reported issue in this script: SC2086:info:9:29: Double quote to prevent globbing and word splitting
(shellcheck)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: push-check
🔇 Additional comments (2)
.github/workflows/Release.yml (2)
16-34
: LGTM! Well-configured setup stepsThe setup is properly configured with latest action versions, explicit version pinning, and correct caching configuration.
8-14
: 🛠️ Refactor suggestionAdd concurrency control to prevent parallel releases
To prevent race conditions from multiple simultaneous releases, add concurrency control:
jobs: release: + concurrency: release-${{ github.ref }} if: github.repository == 'opentiny/tiny-engine' runs-on: ubuntu-latest permissions:
Likely invalid or redundant comment.
.github/workflows/Release.yml
Outdated
- name: Parse Publish tag | ||
id: parse_tag | ||
run: | | ||
tag_name="${GITHUB_REF#refs/tags/}" | ||
if [[ "$tag_name" == *alpha* ]]; then | ||
echo "dist_tag=alpha" >> $GITHUB_OUTPUT | ||
elif [[ "$tag_name" == *beta* ]]; then | ||
echo "dist_tag=beta" >> $GITHUB_OUTPUT | ||
elif [[ "$tag_name" == *rc* ]]; then | ||
echo "dist_tag=rc" >> $GITHUB_OUTPUT | ||
else | ||
echo "dist_tag=latest" >> $GITHUB_OUTPUT | ||
fi | ||
|
||
- name: Verify clean working directory | ||
run: | | ||
if [[ -n $(git status --porcelain) ]]; then | ||
echo "Working directory is not clean" | ||
exit 1 | ||
fi | ||
|
||
- name: Verify package version match tag | ||
run: | | ||
tag_name="${GITHUB_REF#refs/tags/}" | ||
package_version=$(pnpm lerna list --scope=@opentiny/tiny-engine --json | jq -r '.[0].version') | ||
if [[ "$tag_name" != "v$package_version" ]]; then | ||
echo "Tag name $tag_name does not match package version $package_version" | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve shell script safety and tag validation
The shell scripts need proper quoting and additional validation:
- name: Parse Publish tag
id: parse_tag
run: |
+ if [[ ! "$GITHUB_REF" =~ ^refs/tags/v ]]; then
+ echo "Error: Invalid tag format. Must start with 'v'" >&2
+ exit 1
+ fi
tag_name="${GITHUB_REF#refs/tags/}"
if [[ "$tag_name" == *alpha* ]]; then
- echo "dist_tag=alpha" >> $GITHUB_OUTPUT
+ echo "dist_tag=alpha" >> "$GITHUB_OUTPUT"
elif [[ "$tag_name" == *beta* ]]; then
- echo "dist_tag=beta" >> $GITHUB_OUTPUT
+ echo "dist_tag=beta" >> "$GITHUB_OUTPUT"
elif [[ "$tag_name" == *rc* ]]; then
- echo "dist_tag=rc" >> $GITHUB_OUTPUT
+ echo "dist_tag=rc" >> "$GITHUB_OUTPUT"
else
- echo "dist_tag=latest" >> $GITHUB_OUTPUT
+ echo "dist_tag=latest" >> "$GITHUB_OUTPUT"
fi
+ echo "Selected dist_tag: $(cat "$GITHUB_OUTPUT")" >&2
- name: Verify clean working directory
run: |
- if [[ -n $(git status --porcelain) ]]; then
+ if [[ -n "$(git status --porcelain)" ]]; then
📝 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.
- name: Parse Publish tag | |
id: parse_tag | |
run: | | |
tag_name="${GITHUB_REF#refs/tags/}" | |
if [[ "$tag_name" == *alpha* ]]; then | |
echo "dist_tag=alpha" >> $GITHUB_OUTPUT | |
elif [[ "$tag_name" == *beta* ]]; then | |
echo "dist_tag=beta" >> $GITHUB_OUTPUT | |
elif [[ "$tag_name" == *rc* ]]; then | |
echo "dist_tag=rc" >> $GITHUB_OUTPUT | |
else | |
echo "dist_tag=latest" >> $GITHUB_OUTPUT | |
fi | |
- name: Verify clean working directory | |
run: | | |
if [[ -n $(git status --porcelain) ]]; then | |
echo "Working directory is not clean" | |
exit 1 | |
fi | |
- name: Verify package version match tag | |
run: | | |
tag_name="${GITHUB_REF#refs/tags/}" | |
package_version=$(pnpm lerna list --scope=@opentiny/tiny-engine --json | jq -r '.[0].version') | |
if [[ "$tag_name" != "v$package_version" ]]; then | |
echo "Tag name $tag_name does not match package version $package_version" | |
exit 1 | |
fi | |
- name: Parse Publish tag | |
id: parse_tag | |
run: | | |
if [[ ! "$GITHUB_REF" =~ ^refs/tags/v ]]; then | |
echo "Error: Invalid tag format. Must start with 'v'" >&2 | |
exit 1 | |
fi | |
tag_name="${GITHUB_REF#refs/tags/}" | |
if [[ "$tag_name" == *alpha* ]]; then | |
echo "dist_tag=alpha" >> "$GITHUB_OUTPUT" | |
elif [[ "$tag_name" == *beta* ]]; then | |
echo "dist_tag=beta" >> "$GITHUB_OUTPUT" | |
elif [[ "$tag_name" == *rc* ]]; then | |
echo "dist_tag=rc" >> "$GITHUB_OUTPUT" | |
else | |
echo "dist_tag=latest" >> "$GITHUB_OUTPUT" | |
fi | |
echo "Selected dist_tag: $(cat "$GITHUB_OUTPUT")" >&2 | |
- name: Verify clean working directory | |
run: | | |
if [[ -n "$(git status --porcelain)" ]]; then | |
echo "Working directory is not clean" | |
exit 1 | |
fi | |
- name: Verify package version match tag | |
run: | | |
tag_name="${GITHUB_REF#refs/tags/}" | |
package_version=$(pnpm lerna list --scope=@opentiny/tiny-engine --json | jq -r '.[0].version') | |
if [[ "$tag_name" != "v$package_version" ]]; then | |
echo "Tag name $tag_name does not match package version $package_version" | |
exit 1 | |
fi |
🧰 Tools
🪛 actionlint (1.7.4)
48-48: shellcheck reported issue in this script: SC2086:info:3:28: Double quote to prevent globbing and word splitting
(shellcheck)
48-48: shellcheck reported issue in this script: SC2086:info:5:27: Double quote to prevent globbing and word splitting
(shellcheck)
48-48: shellcheck reported issue in this script: SC2086:info:7:25: Double quote to prevent globbing and word splitting
(shellcheck)
48-48: shellcheck reported issue in this script: SC2086:info:9:29: Double quote to prevent globbing and word splitting
(shellcheck)
99c6540
to
ec512c1
Compare
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit