forked from pascalabcnet/pascalabcnet
-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (116 loc) · 5.45 KB
/
build-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
132
133
134
135
136
137
138
139
140
name: Pull upstream / Make a nightly release on Windows [manual + cron]
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.event.schedule || github.ref }}
cancel-in-progress: true
permissions:
contents: write
defaults:
run:
shell: cmd
jobs:
build:
name: Prepare and build on Windows Server VM (2019)
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Pull changes from original repo
run: |
git config --global user.name "BH build bot"
git config --global user.email "SpectatorBH@outlook.com"
git pull https://github.com/pascalabcnet/pascalabcnet.git master
git push
- name: Install dependencies into Virtual Environment
run: _RegisterHelixNUnit.bat
- name: Build C# project in release-mode / compile Pas-units / run tests
run: _GenerateAllSetupsForGitHubActions.bat
timeout-minutes: 40
env:
PABCNET_BUILD_MODE: Release
PABCNET_RUN_TESTS: false
PABCNET_INC_BUILD: false
PABCNET_VERBOSE: false
- name: Prepare GitHub extra scripting packages
run: npm install @actions/exec
- name: Create GitHub Release
uses: actions/github-script@main
with:
script: |
const tag = "nightly-build-synced"; // Git tag name (preferably different from branch name)
const release_name = "Nightly build (upstream synced)"; // GitHub release display name
const mark_pre_release = true;
console.log('environment', process.versions);
sha = '';
await require('@actions/exec').exec('git', ['rev-parse', 'HEAD'], {
listeners: {
stdout: data => {
sha += data.toString().trim();
},
stderr: data => {
sha += data.toString().trim();
}
}
});
const { repo: { owner, repo } } = context;
console.log({ owner, repo, sha });
// Check if the release already exists
const existingReleases = await github.rest.repos.listReleases({ owner, repo });
for (const existingRelease of existingReleases.data) {
if (existingRelease.tag_name === tag) {
console.log('deleting old release', { existingRelease });
await github.rest.repos.deleteRelease({
owner,
repo,
release_id: existingRelease.id,
});
break;
}
}
try {
await github.rest.git.deleteRef({
owner: owner,
repo: repo,
ref: `tags/${tag}`
});
console.log('Tag deleted successfully');
} catch (error) {
console.error(`Error deleting tag: ${error}`);
}
const release = await github.rest.repos.createRelease({
owner, repo,
tag_name: tag,
name: release_name,
draft: true,
prerelease: mark_pre_release,
target_commitish: sha
});
console.log('created release', { release });
const fs = require('fs').promises;
for (let file of await fs.readdir('Release')) {
console.log('uploading', file);
if (file.startsWith('.')) continue;
try {
await github.rest.repos.uploadReleaseAsset({
owner, repo,
release_id: release.data.id,
name: file,
data: await fs.readFile(`./Release/${file}`)
});
} catch (error) {
console.error(`Error uploading: ${error}`);
}
}
if (release.data.draft) {
console.log('finalizing draft release');
await github.rest.repos.updateRelease({
owner,
repo,
release_id: release.data.id,
draft: false,
});
}