Skip to content

chore: 发布流程仅保留 npm 与 pypi 上传 #57

chore: 发布流程仅保留 npm 与 pypi 上传

chore: 发布流程仅保留 npm 与 pypi 上传 #57

Workflow file for this run

name: Release

Check failure on line 1 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

(Line: 40, Col: 9): Unrecognized function: 'hashFiles'. Located at position 124 within expression: ((github.event_name == 'push' && needs.release.outputs.released == 'true') || github.event_name == 'workflow_dispatch') && hashFiles('package.json') != ''
on:
push:
branches:
- main
- beta
workflow_dispatch:
inputs:
ref:
description: Git ref to build (tag/sha/branch). Leave empty to use current.
required: false
default: ""
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
outputs:
released: ${{ steps.semantic.outputs.released }}
version: ${{ steps.semantic.outputs.version }}
tag: ${{ steps.semantic.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Python Semantic Release
id: semantic
if: github.event_name == 'push'
uses: python-semantic-release/python-semantic-release@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish-npm:
needs: release
runs-on: ubuntu-latest
if: ((github.event_name == 'push' && needs.release.outputs.released == 'true') || github.event_name == 'workflow_dispatch') && hashFiles('package.json') != ''
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || needs.release.outputs.tag || github.sha }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public
publish-pypi:
needs: release
runs-on: ubuntu-latest
if: (github.event_name == 'push' && needs.release.outputs.released == 'true') || github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || needs.release.outputs.tag || github.sha }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Build package
run: |
python -m pip install --upgrade pip
python -m pip install build twine
python -m build
python -m twine check dist/*
- name: Upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m twine upload --non-interactive --skip-existing dist/*