feat: update dependencies in release workflow #61
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, macos-13] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pypoetry | |
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | |
- name: Setup Python 3.11 | |
uses: actions/setup-python@v5 | |
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@v4 | |
with: | |
name: cg-x86_64.elf | |
path: cg-x86_64.elf | |
- name: Upload Artifact exe | |
if: matrix.os == 'windows-latest' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cg-x86_64.exe | |
path: cg-x86_64.exe | |
- name: Upload Artifact macho (x86) | |
if: matrix.os == 'macos-13' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cg-x86_64.macho | |
path: cg-x86_64.macho | |
- name: Upload Artifact macho | |
if: matrix.os == 'macos-latest' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cg-arm64.macho | |
path: cg-arm64.macho | |
build_arm: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: [armv7l, aarch64] | |
include: | |
- arch: armv7l | |
cpu: cortex-a7 | |
base_image: raspios_lite:latest | |
cpu_info: cpuinfo/raspberrypi_zero2_w | |
image_additional_mb: 1024 | |
copy_artifacts_on_fail: yes | |
copy_artifact_dest: /release | |
- arch: aarch64 | |
cpu: cortex-a53 | |
base_image: raspios_lite_arm64:latest | |
cpu_info: cpuinfo/raspberrypi_zero2_w_arm64 | |
image_additional_mb: 1024 | |
copy_artifacts_on_fail: yes | |
copy_artifact_dest: /release | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pguyot/arm-runner-action@v2 | |
id: arm_runner_install | |
with: | |
base_image: ${{ matrix.base_image }} | |
cpu: ${{ matrix.cpu }} | |
cpu_info: ${{ matrix.cpu_info }} | |
shell: bash | |
image_additional_mb: ${{ matrix.image_additional_mb }} | |
copy_artifacts_on_fail: ${{ matrix.copy_artifacts_on_fail }} | |
copy_artifact_path: cg-${{ matrix.arch }}.elf | |
commands: | | |
apt-get update -y | |
apt-get install python3-dev python3 python3-pip patchelf ccache libffi-dev -y --no-install-recommends | |
pip install poetry --break-system-packages | |
poetry install | |
df -h | |
ci/build_nuitka/unix.sh | |
mkdir -p ${{ matrix.copy_artifact_dest }} | |
- name: Extract Artifact from output image | |
run: | | |
sudo apt-get install -y fdisk parted | |
chmod +x ./ci/armlinux_loopdev_extract.sh | |
./ci/armlinux_loopdev_extract.sh ${{ steps.arm_runner_install.outputs.image }} cg-${{ matrix.arch }}.elf | |
- name: Upload Artifact (ARM) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cg-${{ matrix.arch }}.elf | |
path: cg-${{ matrix.arch }}.elf | |
release: | |
needs: [build, build_arm] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- 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 -n "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 all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: release/ | |
- name: Generate release environment variables | |
run: | | |
./ci/release_note_generator.sh > release_note.md | |
echo "::set-env name=TAG_NAME::$(cat tag_name.txt)" | |
echo "::set-env name=RELEASE_NOTE::$(cat release_note.md)" | |
echo "::set-env name=RELEASE_NAME::$(echo Release $(cat tag_name.txt))" | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
- 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-*.*" | |
env: | |
GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN2 }} | |
TAG_NAME: ${{ env.TAG_NAME }} | |
RELEASE_NOTE: ${{ env.RELEASE_NOTE }} | |
RELEASE_NAME: ${{ env.RELEASE_NAME }} |