-
Notifications
You must be signed in to change notification settings - Fork 1
125 lines (104 loc) · 3.39 KB
/
build.yml
File metadata and controls
125 lines (104 loc) · 3.39 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
name: Build
on: push
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Create draft release
uses: actions/github-script@0.9.0
if: github.ref == 'refs/heads/master'
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs');
const release = await github.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: new Date().toISOString().replace(/[T:]/g, '-').split('.')[0],
target_commitish: context.sha,
draft: true,
prerelease: true,
});
fs.mkdirSync('release-info');
fs.writeFileSync('release-info/release.json', JSON.stringify({
id: release.data.id,
upload_url: release.data.upload_url,
}));
- name: Upload release-info
uses: actions/upload-artifact@v1
if: github.ref == 'refs/heads/master'
with:
name: release-info
path: release-info
build:
name: ${{ matrix.wheel }}
runs-on: ubuntu-latest
needs: release
container:
image: debian:11
strategy:
matrix:
wheel:
- ns-3
- traci
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Execute ${{ matrix.wheel }}/build.sh
run: exec ./github-action-build.sh ${{ matrix.wheel }}/build.sh
- name: Download release-info
uses: actions/download-artifact@v4.1.7
if: github.ref == 'refs/heads/master'
with:
name: release-info
- name: Upload ${{ matrix.wheel }}
uses: actions/github-script@0.9.0
if: github.ref == 'refs/heads/master'
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs');
const release = JSON.parse(fs.readFileSync('release-info/release.json'), 'utf8');
for (let i = 0; ; i++) {
const path = process.env[`ASSET_PATH_${i}`];
if (!path) {
break;
}
const name = process.env[`ASSET_NAME_${i}`];
const data = fs.readFileSync(path);
console.log(`Upload ${name}: ${path} (${data.length} bytes)`);
await github.repos.uploadReleaseAsset({
url: release.upload_url,
headers: {
'content-type': 'application/zip',
'content-length': data.length,
},
name,
data,
});
}
publish:
name: Publish
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master'
steps:
- name: Download release-info
uses: actions/download-artifact@v4.1.7
with:
name: release-info
- name: Publish release
uses: actions/github-script@0.9.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs');
const release = JSON.parse(fs.readFileSync('release-info/release.json'), 'utf8');
await github.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.id,
draft: false,
});