Skip to content

Commit

Permalink
📦 ci(main.yml): add GitHub Actions workflow for building and releasin…
Browse files Browse the repository at this point in the history
…g the application

The main.yml file contains a GitHub Actions workflow that automates the build and release process for the application. It defines two jobs: "build" and "release". The "build" job builds the application for different operating systems (ubuntu-20.04, windows-latest, macos-latest) using Nuitka and packages the binary into a tar.gz or zip file. The "release" job downloads the artifacts from the "build" job, reorganizes them into a "dist" directory, and creates a draft release on GitHub using the softprops/action-gh-release action. This workflow improves the development process by automating the build and release steps.
  • Loading branch information
hydrotho committed Nov 12, 2023
1 parent 92baea9 commit 03b4f47
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Build and Release

env:
APP_NAME: BiliBili_Livestream_Reminder

on:
push:
tags:
- "v*.*.*"

jobs:
build:
strategy:
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
include:
- os: ubuntu-20.04
arch: x86_64
platform: linux
ext: tar.gz
- os: windows-latest
arch: x86_64
platform: windows
ext: zip
- os: macos-latest
arch: x86_64
platform: darwin
ext: tar.gz

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build Executable
uses: Nuitka/Nuitka-Action@main
with:
nuitka-version: main
script-name: main.py
onefile: true
output-file: ${{ env.APP_NAME }}

- name: Package Binary
shell: bash
run: |
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a ${{ env.APP_NAME }}-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.ext }} build/${{ env.APP_NAME }}.exe
else
tar -czvf ${{ env.APP_NAME }}-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.ext }} -C build ${{ env.APP_NAME }}
fi
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }} Build
path: ${{ env.APP_NAME }}-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.ext }}

release:
needs: build

runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Download Artifacts
uses: actions/download-artifact@v3

- name: Reorganize Artifacts
run: |
mkdir -p dist/
mv */* dist/
- name: Draft Release
uses: softprops/action-gh-release@v1
with:
draft: true
files: dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 03b4f47

Please sign in to comment.