ci(version): bump to v0.3.4.1 #81
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto Release on Version Change | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- 'pyproject.toml' # 当pyproject.toml文件变动时触发 | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
outputs: | |
tag_exists: ${{ steps.check_tag_exists.outputs.exists }} | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
version: ${{ steps.get_version.outputs.version }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.11' | |
- name: Install PDM | |
uses: pdm-project/setup-pdm@v3 | |
- name: Get Project Version | |
id: get_version | |
run: | | |
echo "version=$(pdm show --version)" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Check if Git Tag exists | |
id: check_tag_exists | |
env: | |
VERSION: ${{ steps.get_version.outputs.version }} | |
run: | | |
git fetch --tags | |
if git rev-list -n 1 "v$VERSION" > /dev/null 2>&1; then | |
echo "Tag v$VERSION already exists." | |
echo "exists=1" >> $GITHUB_OUTPUT | |
else | |
echo "Tag v$VERSION does not exist." | |
echo "exists=0" >> $GITHUB_OUTPUT | |
fi | |
shell: bash | |
- name: Create Git Tag | |
if: steps.check_tag_exists.outputs.exists == 0 | |
run: | | |
git tag v${{ steps.get_version.outputs.version }} | |
git push origin v${{ steps.get_version.outputs.version }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
shell: bash | |
- name: Install Dependencies | |
if: steps.check_tag_exists.outputs.exists == 0 | |
run: | | |
pdm install -d | |
pdm list | |
shell: bash | |
- name: build | |
if: steps.check_tag_exists.outputs.exists == 0 | |
run: | | |
eval $(pdm venv activate) | |
make | |
shell: bash | |
- name: rename binary | |
if: steps.check_tag_exists.outputs.exists == 0 | |
run: | | |
mv dist/kazu dist/kazu-linux-${{ steps.get_version.outputs.version }} | |
- name: Render Default State-Transition Diagram | |
if: steps.check_tag_exists.outputs.exists == 0 | |
run: | | |
eval $(pdm venv activate) | |
mkdir -p diagrams | |
kazu viz all -r -d diagrams | |
tar -zcvf diagrams.tar.gz diagrams | |
shell: bash | |
- name: Create GitHub Release | |
if: steps.check_tag_exists.outputs.exists == 0 | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: v${{ steps.get_version.outputs.version }} | |
files: | | |
./dist/* | |
./diagrams.tar.gz | |
draft: false | |
fail_on_unmatched_files: true | |
generate_release_notes: true | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build_win_binary: | |
needs: [release] | |
if: ${{ needs.release.outputs.tag_exists == 0 }} | |
runs-on: windows-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.11' | |
- name: Install PDM | |
uses: pdm-project/setup-pdm@v3 | |
- name: Install Dependencies | |
run: pdm install -d | |
- name: build | |
shell: pwsh | |
run: | | |
$env:PATH = ".venv\Scripts;" + $env:PATH | |
make build_bin | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.release.outputs.upload_url }} | |
asset_path: ./dist/kazu.exe | |
asset_name: kazu-win-${{ needs.release.outputs.version }}.exe | |
asset_content_type: application/octet-stream |