feat: add version tag to release.yml #8
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: Release binary | |
on: | |
push: | |
branches: | |
- release | |
pull_request: | |
branches: | |
- release | |
# This is what will cancel the workflow | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
python-version: [3.11] | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pypoetry | |
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | |
- name: Setup Python 3.11 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.11 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
poetry install | |
- name: Build with Nuitka (windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
ci/build_nuitka/windows.ps1 | |
- name: Build with Nuitka (unix) | |
if: matrix.os != 'windows-latest' | |
run: | | |
ci/build_nuitka/unix.sh | |
- name: Upload Artifact elf | |
if: matrix.os == 'ubuntu-latest' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cg.elf | |
path: cg.elf | |
- name: Upload Artifact exe | |
if: matrix.os == 'windows-latest' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cg.exe | |
path: cg.exe | |
- name: Upload Artifact macho | |
if: matrix.os == 'macos-latest' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cg.macho | |
path: cg.macho | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Create Release Tag | |
run: | | |
git config --local user.email "ci@scc-net.tw" | |
git config --local user.name "CI" | |
VERSION=$(cat pyproject.toml | grep version | cut -d '"' -f 2) | |
echo "v${VERSION}-${{ github.run_number }}-${{ github.sha }}" > tag_name.txt | |
git tag $(cat tag_name.txt) | |
git push origin --tags | |
env: | |
GH_TOKEN: ${{ secrets.DEPLOY_TOKEN2 }} | |
- name: Download cg.elf artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: cg.elf | |
path: release/ | |
- name: Download cg.exe artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: cg.exe | |
path: release/ | |
- name: Download cg.macho artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: cg.macho | |
path: release/ | |
- name: Generate Release note md | |
run: | | |
./ci/release_note_generator.sh > release_note.md | |
- uses: ncipollo/release-action@v1 | |
with: | |
name: ${{ env.RELEASE_NAME }} | |
tag: ${{ env.TAG_NAME }} | |
body: ${{ env.RELEASE_NOTE }} | |
commit: ${{ github.sha }} | |
draft: false | |
prerelease: false | |
artifacts: | | |
release/cg.elf | |
release/cg.exe | |
release/cg.macho | |
env: | |
GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN2 }} | |
TAG_NAME: $(cat tag_name.txt) | |
RELEASE_NOTE: $(cat release_note.md) | |
RELEASE_NAME: $(echo Release $(cat tag_name.txt)) |