mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 02:23:01 +08:00
158 lines
5.7 KiB
YAML
158 lines
5.7 KiB
YAML
name: release-nightly-ota
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
ref:
|
|
description: 'Commit to build (git checkout)'
|
|
type: string
|
|
required: true
|
|
limit:
|
|
description: 'Number of releases to fetch from MaaAssistantArknights'
|
|
required: false
|
|
default: 30
|
|
type: number
|
|
limit_2:
|
|
description: 'Number of releases to fetch from MaaRelease'
|
|
required: false
|
|
default: 30
|
|
tag_name:
|
|
description: 'Tag name to release'
|
|
required: false
|
|
|
|
jobs:
|
|
build-win-nightly:
|
|
runs-on: windows-latest
|
|
outputs:
|
|
tag: ${{ steps.set_tag.outputs.tag }}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
# repository: 'MaaAssistantArknights/MaaAssistantArknights'
|
|
submodules: recursive
|
|
#ref: ${{ inputs.ref }}
|
|
fetch-depth: 0
|
|
- name: Checkout ref
|
|
run: |
|
|
git checkout --progress --recurse-submodules ${{ inputs.ref || 'dev' }}
|
|
- run: |
|
|
npm install --global --progress semver
|
|
- name: Set tag
|
|
id: set_tag
|
|
run: |
|
|
if ("${{ inputs.tag_name }}" -ne "") {
|
|
echo "tag=${{ inputs.tag_name }}" >> $env:GITHUB_OUTPUT
|
|
exit 0
|
|
}
|
|
$described = $(git describe --tags --long --match 'v*')
|
|
$ids = $($described -split "-")
|
|
if ($ids.length -eq 3) {
|
|
$ver = "v$(semver --increment $ids[0].Substring(1))"
|
|
echo "tag=$ver-alpha.0.$($ids[1]).$($ids[2])" >> $env:GITHUB_OUTPUT
|
|
exit 0
|
|
}
|
|
if ($ids.length -eq 4) {
|
|
echo "tag=$($ids[0])-$($ids[1]).$($ids[2]).$($ids[3])" >> $env:GITHUB_OUTPUT
|
|
exit 0
|
|
}
|
|
exit 1
|
|
- name: Cache .nuke/temp, ~/.nuget/packages
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
.nuke/temp
|
|
~/.nuget/packages
|
|
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
|
|
- name: Run './build.cmd DevBuild'
|
|
run: |
|
|
$env:GITHUB_WORKFLOW = 'dev-build-win' # pretend this is a dev-build-win workflow
|
|
$env:MAA_BUILDER_MAA_VERSION = "${{steps.set_tag.outputs.tag}}"
|
|
echo "tag: " $env:MAA_BUILDER_MAA_VERSION
|
|
./build.cmd DevBuild
|
|
env:
|
|
Reason: 'Build nightly version'
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: MAA-win-x64
|
|
path: artifacts
|
|
|
|
make-ota:
|
|
needs: build-win-nightly
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- run: echo ${{ needs.build-win-nightyl.outputs.tag }}
|
|
- name: "Fetch MaaRelease"
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: ${{ format('{0}/{1}', github.repository_owner, 'MaaRelease') }}
|
|
path: MaaRelease
|
|
fetch-depth: 0
|
|
token: ${{ secrets.MAARELEASE_RELEASE }}
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
path: MaaAssistantArknights
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
name: MAA-win-x64
|
|
path: ${{ format('{0}/{1}', 'build-ota', needs.build-win-nightly.outputs.tag) }}
|
|
- name: "Fetch release info"
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
mkdir -pv build-ota && cd build-ota
|
|
cd ${{ needs.build-win-nightly.outputs.tag }}
|
|
mkdir -pv content
|
|
unzip -q *.zip -x '*.lib' -x '*.pdb' -x '*.config' -x '*.xml' -d content
|
|
cd ..
|
|
|
|
gh release list --repo 'MaaAssistantArknights/MaaAssistantArknights' --limit ${{ inputs.limit || 30 }} | tee ./release_maa.txt
|
|
gh release list --repo "${{ github.repository_owner }}/MaaRelease" --limit ${{ inputs.limit_2 || 30 }} | tee ./release_mr.txt
|
|
echo ${{ needs.build-win-nightly.outputs.tag }} > ./config
|
|
|
|
cat ./release_maa.txt | awk '{ print $1 }' > ./tags_maa.txt
|
|
cat ./release_mr.txt | awk '{ print $1 }' > ./tags_mr.txt
|
|
|
|
comm <(sort ./tags_maa.txt) <(sort ./tags_mr.txt) | awk '{ print $1 }' >> ./config
|
|
|
|
echo "config:"
|
|
cat ./config
|
|
|
|
echo "release_tag=$(head -n 1 ./config)" >> $GITHUB_ENV
|
|
- name: "Build OTA"
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
cd build-ota
|
|
$GITHUB_WORKSPACE/MaaAssistantArknights/tools/OTAPacker/build.sh 'MaaAssistantArknights/MaaAssistantArknights' ./config "${{ github.repository_owner }}/MaaRelease"
|
|
mv -v ${{ needs.build-win-nightly.outputs.tag }}/*.zip ./MAA-${{ env.release_tag }}-win-x64.zip
|
|
- name: "Commit and setup tag"
|
|
run: |
|
|
cd MaaRelease
|
|
git config user.name 'github-actions[bot]'
|
|
git config user.email 'github-actions[bot]@users.noreply.github.com'
|
|
git checkout --orphan __temp
|
|
git rm -rf .
|
|
git commit --allow-empty --message ${{ env.release_tag }}
|
|
git tag ${{ env.release_tag }} || exit 0 # do nothing if the tag already exists
|
|
git push --tags
|
|
- name: "Upload to MaaRelease"
|
|
uses: svenstaro/upload-release-action@v2
|
|
with:
|
|
repo_name: ${{ format('{0}/{1}', github.repository_owner, 'MaaRelease') }}
|
|
repo_token: ${{ secrets.MAARELEASE_RELEASE }}
|
|
file_glob: true
|
|
file: build-ota/*.zip
|
|
tag: ${{ env.release_tag }}
|
|
prerelease: true
|
|
overwrite: true
|
|
- name: "Upload to server"
|
|
uses: appleboy/scp-action@master
|
|
with:
|
|
host: ${{ secrets.SSH_HOST }}
|
|
username: ${{ secrets.SSH_USER }}
|
|
key: ${{ secrets.SSH_ID }}
|
|
source: "build-ota/*.zip"
|
|
strip_components: 1
|
|
target: ${{ format('{0}/{1}', 'OTA/MaaAssistantArknights/MaaRelease/releases/download', env.release_tag) }}
|