-
Notifications
You must be signed in to change notification settings - Fork 123
155 lines (139 loc) · 4.59 KB
/
install.yml
File metadata and controls
155 lines (139 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: install
on:
push:
tags:
- "v*"
branches:
- "**"
paths:
- ".github/workflows/install.yml"
- "assets/**"
- "**.py"
pull_request:
branches:
- "**"
paths:
- ".github/workflows/install.yml"
- "assets/**"
- "**.py"
workflow_dispatch:
jobs:
meta:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: set_tag
run: |
is_release=${{ startsWith(github.ref, 'refs/tags/v') }}
tag=$(git describe --tags --match "v*" ${{ github.ref }} || true)
if [[ $tag != v* ]]; then
tag=$(curl -sX GET "https://api.github.com/repos/${{ github.repository }}/releases/latest" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | awk '/tag_name/{print $4}' FS='["]')
if [[ $tag != v* ]]; then
tag="v0.0.0"
fi
tag=$(date "+$tag-%y%m%d-$(git rev-parse --short HEAD)")
fi
if ! $($is_release) ; then
prefix=${tag%-*-*}
suffix=${tag#$prefix-}
tag="$prefix-ci.$suffix"
fi
echo tag=$tag | tee -a $GITHUB_OUTPUT
echo is_release=$is_release | tee -a $GITHUB_OUTPUT
outputs:
tag: ${{ steps.set_tag.outputs.tag }}
is_release: ${{ steps.set_tag.outputs.is_release }}
install:
needs: meta
runs-on: macos-latest
strategy:
matrix:
os: [win, macos, linux, android]
arch: [aarch64, x86_64]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Download MaaFramework
uses: robinraju/release-downloader@v1
with:
repository: MaaXYZ/MaaFramework
fileName: "MAA-${{ matrix.os }}-${{ matrix.arch }}*"
latest: true
out-file-path: "deps"
extract: true
- name: Download MFAAvalonia
if: matrix.os != 'android'
uses: robinraju/release-downloader@v1
with:
repository: SweetSmellFox/MFAAvalonia
fileName: "MFAAvalonia-*-${{ (matrix.os == 'win' && 'win') || (matrix.os == 'macos' && 'osx') || (matrix.os == 'linux' && 'linux') }}-${{ (matrix.arch == 'x86_64' && 'x64') || (matrix.arch == 'aarch64' && 'arm64') }}*"
latest: true
out-file-path: "MFA"
extract: true
- name: Clean up MFAAvalonia archive
if: matrix.os != 'android'
shell: bash
run: |
OS_NAME=""
if [[ "${{ matrix.os }}" == "win" ]]; then
OS_NAME="win"
elif [[ "${{ matrix.os }}" == "macos" ]]; then
OS_NAME="osx"
elif [[ "${{ matrix.os }}" == "linux" ]]; then
OS_NAME="linux"
fi
ARCH_NAME=""
if [[ "${{ matrix.arch }}" == "x86_64" ]]; then
ARCH_NAME="x64"
elif [[ "${{ matrix.arch }}" == "aarch64" ]]; then
ARCH_NAME="arm64"
fi
if [[ -n "$OS_NAME" && -n "$ARCH_NAME" ]]; then
ARCHIVE_PATTERN="MFAAvalonia-*-${OS_NAME}-${ARCH_NAME}*"
echo "Attempting to remove downloaded archive matching: ${ARCHIVE_PATTERN}"
rm -f ${ARCHIVE_PATTERN}
echo "Archive cleanup command executed for MFAAvalonia."
else
echo "OS or Arch name not determined for this matrix combination, skipping MFAAvalonia archive cleanup."
fi
- name: Install
shell: bash
run: |
python ./install.py ${{ needs.meta.outputs.tag }}
if [[ "${{ matrix.os }}" != "android" ]]; then
if [ -d "MFA" ]; then
echo "Copying MFA files to install directory..."
mkdir -p install
rsync -av --ignore-existing MFA/ install/
else
echo "MFA directory not found, skipping copy."
fi
else
echo "Skipping copy MFA for Android."
fi
- uses: actions/upload-artifact@v4
with:
name: MaaXXX-${{ matrix.os }}-${{ matrix.arch }}
path: "install"
release:
if: ${{ needs.meta.outputs.is_release == 'true' }}
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
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@v2
with:
files: assets/*
tag_name: ${{ needs.meta.outputs.tag }}
generate_release_notes: true