forked from micro5k/microg-unofficial-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (129 loc) · 5.68 KB
/
auto-nightly.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
---
# SPDX-FileCopyrightText: (c) 2025 ale5000
# SPDX-License-Identifier: GPL-3.0-or-later
name: "Auto-nightly"
permissions: {}
on:
push:
branches:
- "main"
concurrency:
group: "${{ github.repository_id }}-${{ github.workflow }}"
cancel-in-progress: true
jobs:
base-job:
name: "Nightly"
runs-on: ubuntu-latest
permissions:
contents: write # Needed to create a tag
steps:
- name: "Checkout sources"
uses: actions/checkout@v4
- name: "Setup Java"
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- name: "Build nightly"
id: "build"
shell: bash
run: |
# Building nightly...
BUILD_TYPE='oss' '${{ github.workspace }}/build.sh'
- name: "ZIP info"
run: |
# Retrieve informations...
ZIP_FOLDER='${{ steps.build.outputs.ZIP_FOLDER }}'
ZIP_FILENAME='${{ steps.build.outputs.ZIP_FILENAME }}'
ZIP_VERSION='${{ steps.build.outputs.ZIP_VERSION }}'
ZIP_SHORT_COMMIT_ID='${{ steps.build.outputs.ZIP_SHORT_COMMIT_ID }}'
ZIP_BUILD_TYPE='${{ steps.build.outputs.ZIP_BUILD_TYPE }}'
ZIP_BUILD_TYPE_SUPPORTED='${{ steps.build.outputs.ZIP_BUILD_TYPE_SUPPORTED }}'
ZIP_IS_ALPHA='${{ steps.build.outputs.ZIP_IS_ALPHA }}'
ZIP_SHA256='${{ steps.build.outputs.ZIP_SHA256 }}'
ZIP_MD5='${{ steps.build.outputs.ZIP_MD5 }}'
# Displaying informations...
printf '%s\n' "::notice::Filename: ${ZIP_FILENAME:-Missing}"
printf '%s\n' "::notice::Version: ${ZIP_VERSION:-Missing}"
printf '%s\n' "::notice::Short commit ID: ${ZIP_SHORT_COMMIT_ID:-Missing}"
printf '%s\n' "::notice::Build type: ${ZIP_BUILD_TYPE:?}"
printf '%s\n' "::notice::Build type supported: ${ZIP_BUILD_TYPE_SUPPORTED:?}"
printf '%s\n' "::notice::Is alpha: ${ZIP_IS_ALPHA:-Missing}"
printf '%s\n' "::notice::SHA-256: ${ZIP_SHA256:-Missing}"
printf '%s\n' "::notice::MD5: ${ZIP_MD5:-Missing}"
: "${ZIP_FOLDER:?}" || exit "${?}"
- name: "Do we need to release?"
id: "release-decision"
shell: bash
run: |
# Do we need to release?
git fetch -q origin
CREATE_RELEASE='false'
IS_LATEST_COMMIT='false'
if test '${{ github.sha }}' = "$(git log -n 1 --pretty='%H' 'origin/main' || :)"; then
IS_LATEST_COMMIT='true'
fi
if test "${IS_LATEST_COMMIT:?}" = 'true' && '${{ steps.build.outputs.ZIP_BUILD_TYPE_SUPPORTED == 'true' && steps.build.outputs.ZIP_IS_ALPHA == 'true' && github.event_name != 'pull_request' }}'; then
CREATE_RELEASE='true'
fi
printf 'CREATE_RELEASE=%s\n' "${CREATE_RELEASE:?}" >> "${GITHUB_OUTPUT?}"
printf '%s\n' "${CREATE_RELEASE:?}"
- name: "Delete previous nightly release"
uses: actions/github-script@v7
if: "${{ steps.release-decision.outputs.CREATE_RELEASE == 'true' }}"
with:
retries: 3
script: |
/* jshint esversion: 6 */
const response = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: 'nightly'
}).catch(response => response);
if(response && response.status === 404) {
// There is no previous nightly release, nothing to do
} else if(response && response.status >= 200 && response.status < 300 && response.data && response.data.id && response.data.tag_name === 'nightly') {
await github.rest.repos.deleteRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: response.data.id
});
console.log('Previous nightly release deleted: ' + response.data.name + ' (' + response.data.id + ')');
} else {
if(response && response.message) console.error('::error::' + response.message);
throw new Error('getReleaseByTag failed.');
}
await github.rest.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'tags/nightly',
sha: context.sha,
force: true
}).then(response => {
console.log('Previous nightly tag updated.');
}).catch(error => {
if(error.status !== 422 || error.message !== 'Reference does not exist') throw error;
});
- name: "Create nightly release"
uses: softprops/action-gh-release@v2
if: "${{ steps.release-decision.outputs.CREATE_RELEASE == 'true' }}"
with:
name: "Nightly build"
tag_name: "nightly"
target_commitish: "${{ github.sha }}"
body: "Latest automatically built ZIP (unstable development snapshot)\n\nSHA-256: ${{ steps.build.outputs.ZIP_SHA256 }}"
append_body: false
generate_release_notes: false
make_latest: false
draft: false
prerelease: true
files: "${{ steps.build.outputs.ZIP_FOLDER }}/*.zip*"
fail_on_unmatched_files: true
- name: "Upload artifacts"
uses: actions/upload-artifact@v4
if: "${{ steps.build.outputs.ZIP_BUILD_TYPE_SUPPORTED == 'true' }}"
with:
name: "${{ github.event.repository.name }}-${{ steps.build.outputs.ZIP_VERSION }}-${{ steps.build.outputs.ZIP_SHORT_COMMIT_ID }}-${{ steps.build.outputs.ZIP_BUILD_TYPE }} archive (extract it)"
path: "${{ steps.build.outputs.ZIP_FOLDER }}/*.zip*"
if-no-files-found: "error"
retention-days: 7