Skip to content

Commit

Permalink
ci: init
Browse files Browse the repository at this point in the history
  • Loading branch information
dongwlin committed Sep 5, 2023
1 parent d008d89 commit 2eb22b1
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/update_resource_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import sys
import json

if len(sys.argv) < 3:
print("Usage: python update_resource_version.py <properties_file> <version>")
exit(1)

properties_file = sys.argv[1]
version = sys.argv[2]

with open(properties_file, "r") as f:
data = json.load(f)

data["version"] = version

with open(properties_file, "w") as f:
json.dump(data, f, indent=4)
94 changes: 94 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: build cli

on:
push:
tags:
- 'v*'
branches:
- '**'
paths:
- '.github/workflows/ci.yml'
- 'source/cli/**'
- 'assets/**'
- 'MaaFrameworkDownloader.py'
pull_request:
branches:
- '**'
paths:
- '.github/workflows/ci.yml'
- 'source/cli/**'
- 'assets/**'
- 'MaaFrameworkDownloader.py'
workflow_dispatch:

jobs:
meta:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.set_tag.outputs.tag }}
steps:
- uses: actions/checkout@v3
- id: set_tag
run: |
echo tag=$(git describe --tags --match "v*" ${{ github.ref }} || git rev-parse --short HEAD) | tee -a $GITHUB_OUTPUT
windows:
needs: meta
strategy:
matrix:
include:
- msbuild_target: x64
lowercase_target: x64
runs-on: windows-latest

steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Update resource version
run: |
python3 .github/update_resource_version.py assets/resource/properties.json ${{ needs.meta.outputs.tag }}
- name: Download MaaFramework
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python3 MaaFrameworkDownloader.py
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1

- name: Build MAA
run: |
MSBUILD source/cli/MAABH3_CLI.sln /t:rebuild /p:Configuration="Release" /p:Platform="${{ matrix.msbuild_target }}" /m /p:MAA_VERSION="${{ needs.meta.outputs.tag }}"
- name: Install
shell: bash
run: |
cd source/cli/${{ matrix.msbuild_target }}/Release
mkdir -p install
cp -r resource MaaAgentBinary *.exe *.dll install
- uses: actions/upload-artifact@v3
with:
name: MAABH3-win-${{ matrix.msbuild_target }}
path: source/cli/${{ matrix.msbuild_target }}/Release/install

release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [meta, windows]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
path: assets
- run: |
cd assets
for f in *; do
(cd $f && zip -r ../$f-${{ needs.meta.outputs.tag }}.zip .)
done
- uses: softprops/action-gh-release@v1
with:
files: assets/*
tag_name: ${{ needs.meta.outputs.tag }}

0 comments on commit 2eb22b1

Please sign in to comment.