Skip to content

Commit

Permalink
ci: add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Dissectum committed Sep 13, 2023
1 parent cbb8cb0 commit ac55c95
Show file tree
Hide file tree
Showing 5 changed files with 275 additions and 13 deletions.
114 changes: 114 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: ci

on:
workflow_dispatch:
push:
branches:
- "**"
paths:
- ".github/workflows/ci.yml"
- "src/**"
- "*.sln"
- "*.props"
tags:
- "v*"

pull_request:
branches:
- "**"
paths:
- ".github/workflows/ci.yml"
- "src/**"
- "*.sln"
- "*.props"

jobs:
meta:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: meta
shell: bash
run: |
is_release=${{ startsWith(github.ref, 'refs/tags/v') }}
tag=$(git describe --tags --match "v*" ${{ github.ref }} || true)
if ! $($is_release) ; then
prefix=${tag%-*-*}
suffix=${tag#$prefix-}
tag="$prefix-Preview.$suffix"
fi
echo tag=$tag | tee -a $GITHUB_OUTPUT
echo version=${tag#v} | tee -a $GITHUB_OUTPUT
echo is_release=$is_release | tee -a $GITHUB_OUTPUT
outputs:
tag: ${{ steps.meta.outputs.tag }}
version: ${{ steps.meta.outputs.version }}
is_release: ${{ steps.meta.outputs.is_release }}

publish:
needs: [meta]
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
arch: [aarch64, x86_64]
dotnet: [ '7.0' ]
fail-fast: false

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet }}
cache: true
cache-dependency-path: '**/packages.lock.json'
- run: dotnet restore --locked-mode

- name: Build
id: build
shell: bash
run: |
dotnet publish \
--configuration Release \
--no-restore \
--self-contained true \
-p:Version=${{ needs.meta.outputs.version }} \
-p:PublishSingleFile=true \
-p:PublishTrimmed=true
RID=$(ls ./src/MBA.Cli/bin/Release/net${{ matrix.dotnet }}/)
echo RID=RID | tee -a $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
if: always()
with:
name: MBA-${{ steps.build.outputs.RID }}
path: "src/MBA.Cli/bin/Release/net${{ matrix.dotnet }}/${{ steps.build.outputs.RID }}/publish"

release:
#if: ${{ needs.meta.outputs.is_release == 'true' }}
needs: [meta, publish]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
path: assets

- run: |
cd assets
ls -al
for f in *; do
ls -al
(cd $f && zip -r ../$f-${{ needs.meta.outputs.tag }}.zip .)
done
- uses: softprops/action-gh-release@v1
if: false
with:
files: assets/*.zip
tag_name: ${{ needs.meta.outputs.tag }}
14 changes: 14 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,18 @@
<PackageReference Include="Serilog.Sinks.Console" />
<PackageReference Include="Serilog.Sinks.File" />
</ItemGroup>

<!-- Metadata Variable -->
<PropertyGroup>
<CurrentYear>$([System.DateTime]::Now.Year)</CurrentYear>
</PropertyGroup>

<!-- Assembly Metadata-->
<PropertyGroup>
<Version Condition="'$(Version)' == ''">1.0.0-dev</Version>
<Authors>MAA Team</Authors>
<Owners>MAA Team</Owners>
<Company>MAA Assistant Arknights</Company>
<Copyright>Copyright © 2021-$(CurrentYear) MAA Team and Contributers. All rights reserved.</Copyright>
</PropertyGroup>
</Project>
27 changes: 14 additions & 13 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Maa.AgentBinary" Version="1.0.0" />
<PackageVersion Include="Maa.Framework.Runtimes" Version="0.3.7" />
<PackageVersion Include="Maa.ToolKit.Extensions" Version="0.6.0-beta.1.1" />
<PackageVersion Include="Serilog" Version="3.0.1" />
<PackageVersion Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageVersion Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageVersion Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>
</Project>
<PropertyGroup>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Maa.AgentBinary" Version="1.0.0" />
<PackageVersion Include="Maa.Framework.Runtimes" Version="0.3.7" />
<PackageVersion Include="Maa.ToolKit.Extensions" Version="0.6.0-beta.1.1" />
<PackageVersion Include="Serilog" Version="3.0.1" />
<PackageVersion Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageVersion Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageVersion Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>
</Project>
72 changes: 72 additions & 0 deletions src/MBA.Cli/packages.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"version": 2,
"dependencies": {
"net7.0": {
"Serilog": {
"type": "Direct",
"requested": "[3.0.1, )",
"resolved": "3.0.1",
"contentHash": "E4UmOQ++eNJax1laE+lws7E3zbhKgHsGJbO7ra0yE5smUh+5FfUPIKKBxM3MO1tK4sgpQke6/pLReDxIc/ggNw=="
},
"Serilog.Sinks.Console": {
"type": "Direct",
"requested": "[4.1.0, )",
"resolved": "4.1.0",
"contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==",
"dependencies": {
"Serilog": "2.10.0"
}
},
"Serilog.Sinks.Debug": {
"type": "Direct",
"requested": "[2.0.0, )",
"resolved": "2.0.0",
"contentHash": "Y6g3OBJ4JzTyyw16fDqtFcQ41qQAydnEvEqmXjhwhgjsnG/FaJ8GUqF5ldsC/bVkK8KYmqrPhDO+tm4dF6xx4A==",
"dependencies": {
"Serilog": "2.10.0"
}
},
"Serilog.Sinks.File": {
"type": "Direct",
"requested": "[5.0.0, )",
"resolved": "5.0.0",
"contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==",
"dependencies": {
"Serilog": "2.10.0"
}
},
"mba.core": {
"type": "Project",
"dependencies": {
"Maa.AgentBinary": "[1.0.0, )",
"Maa.ToolKit.Extensions": "[0.6.0-beta.1.1, )",
"Serilog": "[3.0.1, )",
"Serilog.Sinks.Console": "[4.1.0, )",
"Serilog.Sinks.Debug": "[2.0.0, )",
"Serilog.Sinks.File": "[5.0.0, )"
}
},
"Maa.AgentBinary": {
"type": "CentralTransitive",
"requested": "[1.0.0, )",
"resolved": "1.0.0",
"contentHash": "09TsLd4LbaxoK68AZAg4MZFle/kkX8JZTbjRbkJYptyUCPCtdbVr8odukKG1CUzL4Wumbu+Fk7ppNX/OSlRMOA=="
},
"Maa.Framework.Runtimes": {
"type": "CentralTransitive",
"requested": "[0.3.7, )",
"resolved": "0.6.0-beta.1",
"contentHash": "aXkvpmPOa4zkguYaOOqWz0Pvfk0aexplmz6OGhfV7exREKw52ZArJqQE1jd1e/oBZ88q5Qhz3IYDeH2RppwQiA=="
},
"Maa.ToolKit.Extensions": {
"type": "CentralTransitive",
"requested": "[0.6.0-beta.1.1, )",
"resolved": "0.6.0-beta.1.1",
"contentHash": "rwnJNWaccmX27scx953IvFUtyfiFNIg8ePecBLX2ewsSy6s/SklPl0+XpfmNRD8ltTTdRzz+2fNuAbB2pxZJ8g==",
"dependencies": {
"Maa.Framework.Runtimes": "0.6.0-beta.1"
}
}
}
}
}
61 changes: 61 additions & 0 deletions src/MBA.Core/packages.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"version": 2,
"dependencies": {
"net7.0": {
"Maa.AgentBinary": {
"type": "Direct",
"requested": "[1.0.0, )",
"resolved": "1.0.0",
"contentHash": "09TsLd4LbaxoK68AZAg4MZFle/kkX8JZTbjRbkJYptyUCPCtdbVr8odukKG1CUzL4Wumbu+Fk7ppNX/OSlRMOA=="
},
"Maa.ToolKit.Extensions": {
"type": "Direct",
"requested": "[0.6.0-beta.1.1, )",
"resolved": "0.6.0-beta.1.1",
"contentHash": "rwnJNWaccmX27scx953IvFUtyfiFNIg8ePecBLX2ewsSy6s/SklPl0+XpfmNRD8ltTTdRzz+2fNuAbB2pxZJ8g==",
"dependencies": {
"Maa.Framework.Runtimes": "0.6.0-beta.1"
}
},
"Serilog": {
"type": "Direct",
"requested": "[3.0.1, )",
"resolved": "3.0.1",
"contentHash": "E4UmOQ++eNJax1laE+lws7E3zbhKgHsGJbO7ra0yE5smUh+5FfUPIKKBxM3MO1tK4sgpQke6/pLReDxIc/ggNw=="
},
"Serilog.Sinks.Console": {
"type": "Direct",
"requested": "[4.1.0, )",
"resolved": "4.1.0",
"contentHash": "K6N5q+5fetjnJPvCmkWOpJ/V8IEIoMIB1s86OzBrbxwTyHxdx3pmz4H+8+O/Dc/ftUX12DM1aynx/dDowkwzqg==",
"dependencies": {
"Serilog": "2.10.0"
}
},
"Serilog.Sinks.Debug": {
"type": "Direct",
"requested": "[2.0.0, )",
"resolved": "2.0.0",
"contentHash": "Y6g3OBJ4JzTyyw16fDqtFcQ41qQAydnEvEqmXjhwhgjsnG/FaJ8GUqF5ldsC/bVkK8KYmqrPhDO+tm4dF6xx4A==",
"dependencies": {
"Serilog": "2.10.0"
}
},
"Serilog.Sinks.File": {
"type": "Direct",
"requested": "[5.0.0, )",
"resolved": "5.0.0",
"contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==",
"dependencies": {
"Serilog": "2.10.0"
}
},
"Maa.Framework.Runtimes": {
"type": "CentralTransitive",
"requested": "[0.3.7, )",
"resolved": "0.6.0-beta.1",
"contentHash": "aXkvpmPOa4zkguYaOOqWz0Pvfk0aexplmz6OGhfV7exREKw52ZArJqQE1jd1e/oBZ88q5Qhz3IYDeH2RppwQiA=="
}
}
}
}

0 comments on commit ac55c95

Please sign in to comment.