👷 CI: 修复 Release 权限错误 (#2381)

This commit is contained in:
Ju4tCode 2023-10-01 15:15:32 +08:00 committed by GitHub
parent 0d84bf3592
commit f77dc523e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,6 +59,9 @@ jobs:
release: release:
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps: steps:
- name: Generate token - name: Generate token
id: generate-token id: generate-token
@ -78,39 +81,53 @@ jobs:
- name: Build API Doc - name: Build API Doc
uses: ./.github/actions/build-api-doc uses: ./.github/actions/build-api-doc
- run: | - name: Get Version
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV id: version
run: |
echo "VERSION=$(poetry version -s)" >> $GITHUB_OUTPUT
echo "TAG_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Check Version
if: steps.version.outputs.VERSION != steps.version.outputs.TAG_VERSION
run: exit 1
- uses: release-drafter/release-drafter@v5 - uses: release-drafter/release-drafter@v5
with: with:
name: Release ${{ env.TAG_NAME }} 🌈 name: Release ${{ steps.version.outputs.TAG_NAME }} 🌈
tag: ${{ env.TAG_NAME }} tag: ${{ steps.version.outputs.TAG_NAME }}
publish: true publish: true
env: env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: Build and Publish Package - name: Build Package
run: | run: |
poetry build poetry build
gh release upload --clobber ${{ env.TAG_NAME }} dist/*.tar.gz dist/*.whl
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: Publish package to PyPI - name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1 uses: pypa/gh-action-pypi-publish@release/v1
- name: Publish package to GitHub
run: |
gh release upload --clobber ${{ steps.version.outputs.TAG_NAME }} dist/*.tar.gz dist/*.whl
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: Build and Publish Doc Package - name: Build and Publish Doc Package
run: | run: |
yarn build:plugin --out-dir ../packages/nonebot-plugin-docs/nonebot_plugin_docs/dist yarn build:plugin --out-dir ../packages/nonebot-plugin-docs/nonebot_plugin_docs/dist
export NONEBOT_VERSION=`poetry version -s`
cd packages/nonebot-plugin-docs/ cd packages/nonebot-plugin-docs/
poetry version $NONEBOT_VERSION poetry version ${{ steps.version.outputs.VERSION }}
poetry build poetry build
gh release upload --clobber ${{ env.TAG_NAME }} dist/*.tar.gz dist/*.whl
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: Publish Doc Package to PyPI - name: Publish Doc Package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1 uses: pypa/gh-action-pypi-publish@release/v1
with: with:
packages-dir: packages/nonebot-plugin-docs/ packages-dir: packages/nonebot-plugin-docs/
- name: Publish Doc Package to GitHub
run: |
cd packages/nonebot-plugin-docs/
gh release upload --clobber ${{ steps.version.outputs.TAG_NAME }} dist/*.tar.gz dist/*.whl
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}