Skip to content

Conversation

@YyumeiZhang
Copy link
Collaborator

中文模板 / Chinese Template

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Test Case
  • TypeScript definition update
  • Document improve
  • CI/CD improve
  • Branch sync
  • Other, please describe:

PR description

Fixes #

Changelog

🇨🇳 Chinese

  • Fix: 修复 ...

🇺🇸 English

  • Fix: fix ...

Checklist

  • Test or no need
  • Document or no need
  • Changelog or no need

Other

  • Skip Changelog

Additional information

Comment on lines 70 to 146
name: Build and Publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref_name }}
run: echo "branch=${{ github.head_ref || github.ref_name }}"


- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'

# 安装
- name: npm install
run: npm i -g lerna@^4.0.0 && npm run bootstrap

# 生成 semi-ui-19 的包
# if: ${{ github.event.inputs.publish_react19 == 'true' }}
- name: Build React 19 version
run: |
node scripts/react19-build.js 19

# 再运行一次,保证 semi-ui-19 中的包正确
- name: npm install again
run: npm run bootstrap

# 测试时候,暂时使用 RELEASE_TYPE: alpha,实际使用请修改为 ${{ github.event.inputs.release_type }}
- name: get version list
run: |
PKG_NAME=@douyinfe/semi-ui
echo "VERSION_LIST="$(npm view $PKG_NAME versions --json)"" >> $GITHUB_ENV

- name: get version
run: echo "RELEASE_VERSION="$(node scripts/version.js)"" >> $GITHUB_ENV
env:
RELEASE_TYPE: alpha

# publish 的时候不提交 semi-ui-19 相关的修改
# 合入到主分支前请将 DIST_TAG=alpha 位置的代码修改为下面的代码
# DIST_TAG=latest
# if [[ ${{ github.event.inputs.release_type }} == 'beta' ]]; then
# DIST_TAG=beta
# elif [[ ${{ github.event.inputs.release_type }} == 'alpha' ]]; then
# DIST_TAG=alpha
# fi
- name: publish
run: |
git config --global user.name 'semi-team'
git config --global user.email '[email protected]'
node scripts/sitemap_update.js
if [ -n "$(git status --porcelain)" ]; then
echo "there are changes";
git add . ':(exclude)packages/semi-ui-19'
git commit --no-verify -m "chore: publish ${{ env.RELEASE_VERSION }}"
else
echo "no changes";
fi
git add packages/semi-ui-19
git commit --no-verify -m "chore: semi-ui-19-related"
npm config set registry=https://registry.npmjs.org/
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm whoami
DIST_TAG=alpha
echo "$RELEASE_VERSION"
echo "$DIST_TAG"
lerna version $RELEASE_VERSION --exact --force-publish --yes --no-push
lerna publish from-package --dist-tag $DIST_TAG --yes
git reset HEAD~2
rm -rf packages/semi-ui-19
git add .
git commit --no-verify -m "v${{env.RELEASE_VERSION}}"
git push -o ci.skip --follow-tags --no-verify --atomic

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI about 1 month ago

To fix the problem, add a permissions: block to the workflow, either at the root level (affecting all jobs unless overridden) or to the specific job (build-and-publish). It's best to review what permissions are actually required:

  • The job pushes commits and tags (git push), and uses lerna publish to publish to npm, indicating it needs at least contents: write (for pushing changes/tags), and possibly packages: write (to publish to npm via GitHub registry, but the workflow seems to push directly to npmjs.org).
  • If opening or updating pull requests, it would need pull-requests: write, but no evidence of that here.
  • If it only needs to read content and push commits/tags, then contents: write is typically sufficient.

The recommended minimal explicit permissions block for the workflow is:

permissions:
  contents: write

This should be placed at the very top of the file, after name: and before on:. Alternatively, if only the build-and-publish job needs these permissions, you can place it under that job.

If you want to be extra careful and only grant contents: write to the build-and-publish job (not all jobs), add the permissions: block inside the job, at the same level as runs-on:.

For clarity, the fix will add the permissions block at the workflow root.


Suggested changeset 1
.github/workflows/react-versions.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/react-versions.yml b/.github/workflows/react-versions.yml
--- a/.github/workflows/react-versions.yml
+++ b/.github/workflows/react-versions.yml
@@ -1,4 +1,6 @@
 name: React Multi-Version Build and Publish
+permissions:
+  contents: write
 
 on:
   pull_request:
EOF
@@ -1,4 +1,6 @@
name: React Multi-Version Build and Publish
permissions:
contents: write

on:
pull_request:
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants