forked from MCCTeam/Minecraft-Console-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
206 lines (175 loc) · 7.74 KB
/
build-and-release.yml
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: Build MCC and Documents
on:
push:
branches:
- master
workflow_dispatch:
env:
PROJECT: "MinecraftClient"
target-version: "net7.0"
compile-flags: "--self-contained=true -c Release -p:UseAppHost=true -p:IncludeNativeLibrariesForSelfExtract=true -p:EnableCompressionInSingleFile=true -p:DebugType=None"
jobs:
build:
runs-on: ubuntu-latest
if: ${{ always() && needs.fetch-translations.result != 'failure' }}
needs: [determine-build, fetch-translations]
timeout-minutes: 15
strategy:
matrix:
target: [win-x86, win-x64, win-arm, win-arm64, linux-x64, linux-arm, linux-arm64, osx-x64, osx-arm64]
steps:
- name: Checkout
uses: actions/checkout@v3
if: ${{ always() && needs.fetch-translations.result == 'skipped' }}
with:
fetch-depth: 0
submodules: 'true'
- name: Get Current Date
run: |
echo date=$(date +'%Y%m%d') >> $GITHUB_ENV
echo date_dashed=$(date -u +'%Y-%m-%d') >> $GITHUB_ENV
- name: Restore Translations (if available)
uses: actions/cache/restore@v3
with:
path: ${{ github.workspace }}/*
key: "translation-${{ github.sha }}"
restore-keys: "translation-"
- name: Setup Environment Variables (early)
run: |
echo project-path=${{ github.workspace }}/${{ env.PROJECT }} >> $GITHUB_ENV
echo file-ext=${{ (startsWith(matrix.target, 'win') && '.exe') || ' ' }} >> $GITHUB_ENV
- name: Setup Environment Variables
run: |
echo target-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/${{ matrix.target }}/publish/ >> $GITHUB_ENV
echo assembly-info=${{ env.project-path }}/Properties/AssemblyInfo.cs >> $GITHUB_ENV
echo build-version-info=${{ env.date }}-${{ github.run_number }} >> $GITHUB_ENV
echo commit=$(echo ${{ github.sha }} | cut -c 1-7) >> $GITHUB_ENV
- name: Setup Environment Variables (late)
run: |
echo built-executable-path=${{ env.target-out-path }}${{ env.PROJECT }}${{ env.file-ext }} >> $GITHUB_ENV
- name: Set Version Info
run: |
echo '' >> ${{ env.assembly-info }}
echo "[assembly: AssemblyConfiguration(\"GitHub build ${{ github.run_number }}, built on ${{ env.date_dashed }} from commit ${{ env.commit }}\")]" >> ${{ env.assembly-info }}
- name: Build Target
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r ${{ matrix.target }} ${{ env.compile-flags }}
env:
DOTNET_NOLOGO: true
- name: Target Publish Executable
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mode: uploadReleaseAsset
filePath: ${{ env.built-executable-path }}
assetName: ${{ env.PROJECT }}-${{ env.build-version-info }}-${{ matrix.target }}${{ (startsWith(matrix.target, 'win') && '.exe') || ' ' }}
tag: ${{ format('{0}-{1}', env.date, github.run_number) }}
fetch-translations:
strategy:
fail-fast: true
runs-on: ubuntu-latest
needs: determine-build
# Translations will only be fetched in the MCCTeam repository, since it needs crowdin secrets.
if: ${{ github.repository == 'MCCTeam/Minecraft-Console-Client' }}
timeout-minutes: 15
steps:
- name: Check cache
uses: actions/cache/restore@v3
id: cache-check
with:
path: ${{ github.workspace }}/*
key: "translation-${{ github.sha }}"
lookup-only: true
restore-keys: "translation-"
- name: Checkout
uses: actions/checkout@v3
if: steps.cache-check.outputs.cache-hit != 'true'
with:
fetch-depth: 0
submodules: 'true'
- name: Download translations from crowdin
uses: crowdin/[email protected]
if: steps.cache-check.outputs.cache-hit != 'true'
with:
upload_sources: false
upload_translations: false
download_translations: true
localization_branch_name: l10n_master
create_pull_request: false
push_translations: false
base_path: ${{ github.workspace }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_TOKEN }}
- name: Save cache
uses: actions/cache/save@v3
if: steps.cache-check.outputs.cache-hit != 'true'
with:
path: ${{ github.workspace }}/*
key: "translation-${{ github.sha }}"
build-transition-version:
runs-on: ubuntu-latest
if: ${{ always() && needs.fetch-translations.result != 'failure' }}
needs: [determine-build, fetch-translations]
timeout-minutes: 15
strategy:
fail-fast: true
matrix:
target: [win-x86, win-x64, linux-x64, linux-arm64, osx-x64]
steps:
- name: Checkout
uses: actions/checkout@v3
if: ${{ always() && needs.fetch-translations.result == 'skipped' }}
with:
fetch-depth: 0
submodules: 'true'
- name: Get Current Date
run: |
echo date=$(date +'%Y%m%d') >> $GITHUB_ENV
echo date_dashed=$(date -u +'%Y-%m-%d') >> $GITHUB_ENV
- name: Restore Translations (if available)
uses: actions/cache/restore@v3
with:
path: ${{ github.workspace }}/*
key: "translation-${{ github.sha }}"
restore-keys: "translation-"
- name: Setup Environment Variables (early)
run: |
echo project-path=${{ github.workspace }}/${{ env.PROJECT }} >> $GITHUB_ENV
echo file-ext=${{ (startsWith(matrix.target, 'win') && '.exe') || ' ' }} >> $GITHUB_ENV
- name: Setup Environment Variables
run: |
echo target-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/${{ matrix.target }}/publish/ >> $GITHUB_ENV
echo assembly-info=${{ env.project-path }}/Properties/AssemblyInfo.cs >> $GITHUB_ENV
echo build-version-info=${{ env.date_dashed }}-${{ github.run_number }} >> $GITHUB_ENV
echo commit=$(echo ${{ github.sha }} | cut -c 1-7) >> $GITHUB_ENV
- name: Setup Environment Variables (late)
run: |
echo built-executable-path=${{ env.target-out-path }}${{ env.PROJECT }}${{ env.file-ext }} >> $GITHUB_ENV
- name: Set Version Info
run: |
echo '' >> ${{ env.assembly-info }}
echo "[assembly: AssemblyConfiguration(\"GitHub build ${{ github.run_number }}, built on ${{ env.date_dashed }} from commit ${{ env.commit }}\")]" >> ${{ env.assembly-info }}
- name: Build Target
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r ${{ matrix.target }} ${{ env.compile-flags }}
env:
DOTNET_NOLOGO: true
- name: Zip Target
run: zip -qq -r mcc-${{ matrix.target }}.zip *
working-directory: ${{ env.target-out-path }}
- name: Target Publish Executable
uses: tix-factory/release-manager@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mode: uploadReleaseAsset
filePath: ${{ env.target-out-path }}/mcc-${{ matrix.target }}.zip
assetName: ${{ env.PROJECT }}-${{ (contains(matrix.target, 'linux-x64') && 'linux.zip') || (contains(matrix.target, 'win-x86') && 'windows-x86.zip') || (contains(matrix.target, 'win-x64') && 'windows-x64.zip') || (contains(matrix.target, 'linux-arm64') && 'linux-arm64.zip') || (contains(matrix.target, 'osx-x64') && 'osx.zip') }}
tag: ${{ format('{0}-{1}', env.date, github.run_number) }}
determine-build:
runs-on: ubuntu-latest
strategy:
fail-fast: true
if: ${{ !contains(github.event.head_commit.message, 'skip ci') }}
steps:
- name: dummy action
run: "echo 'dummy action'"