From 03b4f47cecd1113185b444cd7109d5989ea7458b Mon Sep 17 00:00:00 2001 From: hydrotho <42911474+hydrotho@users.noreply.github.com> Date: Sun, 12 Nov 2023 20:06:58 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20ci(main.yml):=20add=20GitHub=20A?= =?UTF-8?q?ctions=20workflow=20for=20building=20and=20releasing=20the=20ap?= =?UTF-8?q?plication=20The=20main.yml=20file=20contains=20a=20GitHub=20Act?= =?UTF-8?q?ions=20workflow=20that=20automates=20the=20build=20and=20releas?= =?UTF-8?q?e=20process=20for=20the=20application.=20It=20defines=20two=20j?= =?UTF-8?q?obs:=20"build"=20and=20"release".=20The=20"build"=20job=20build?= =?UTF-8?q?s=20the=20application=20for=20different=20operating=20systems?= =?UTF-8?q?=20(ubuntu-20.04,=20windows-latest,=20macos-latest)=20using=20N?= =?UTF-8?q?uitka=20and=20packages=20the=20binary=20into=20a=20tar.gz=20or?= =?UTF-8?q?=20zip=20file.=20The=20"release"=20job=20downloads=20the=20arti?= =?UTF-8?q?facts=20from=20the=20"build"=20job,=20reorganizes=20them=20into?= =?UTF-8?q?=20a=20"dist"=20directory,=20and=20creates=20a=20draft=20releas?= =?UTF-8?q?e=20on=20GitHub=20using=20the=20softprops/action-gh-release=20a?= =?UTF-8?q?ction.=20This=20workflow=20improves=20the=20development=20proce?= =?UTF-8?q?ss=20by=20automating=20the=20build=20and=20release=20steps.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 94 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..968162a --- /dev/null +++ b/.github/workflows/main.yml @@ -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 }}