-
Notifications
You must be signed in to change notification settings - Fork 16
166 lines (147 loc) · 5.03 KB
/
build.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
name: build
on:
push:
tags:
- "v*.*.*"
schedule:
- cron: "0 20 * * 0"
workflow_dispatch:
defaults:
run:
shell: bash
env:
CARGO_INCREMENTAL: "0"
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' && github.event_name != 'merge_group' }}
jobs:
draft-release:
name: Create a release draft
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-22.04
outputs:
release-id: ${{ steps.create-release.outputs.id }}
upload-url: ${{ steps.create-release.outputs.upload_url }}
html-url: ${{ steps.create-release.outputs.html_url }}
timeout-minutes: 50
permissions:
contents: write
steps:
- name: Create release
id: create-release
uses: ncipollo/release-action@v1
with:
allowUpdates: false
draft: true
generateReleaseNotes: true
plan:
name: Plan the execution
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Compute matrix
uses: ./.github/actions/plan
id: set-matrix
with:
plan-name: build
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJson(steps.set-matrix.outputs.matrix) }}
run: echo "$MATRIX_CONTEXT"
build:
needs:
- plan
- draft-release
if: ${{ always() && needs.plan.result == 'success' && (!startsWith(github.ref, 'refs/tags/') || needs.draft-release.result == 'success') }}
strategy:
matrix: ${{ fromJson(needs.plan.outputs.matrix) }}
fail-fast: false
name: ${{ matrix.plan.platform.name }} / ${{ matrix.plan.mode.name }}
runs-on: ${{ matrix.plan.platform.os }}
env: ${{ matrix.plan.platform.env }}
timeout-minutes: 120
permissions:
contents: write
steps:
- name: Job config
run: printf "%s\n" "$MATRIX_CONTEXT"
env:
MATRIX_CONTEXT: ${{ toJson(matrix) }}
- name: Checkout
uses: actions/checkout@v4
timeout-minutes: 5
- uses: ./.github/actions/common-setup
with:
platformCacheKey: ${{ matrix.plan.platform.cacheKey }}
modeCacheKey: ${{ matrix.plan.mode.cargoCacheKey }}
isOnSelfHostedRunner: ${{ matrix.plan.platform.isOnSelfHostedRunner }}
buildEnvScript: ${{ matrix.plan.platform.buildEnvScript }}
timeout-minutes: 10
- name: Run cargo ${{ matrix.plan.mode.cargoCommand }}
run: cargo ${{ matrix.plan.mode.cargoCommand }} ${{ matrix.plan.mode.cargoArgs }}
- name: Set the upload params
id: set-upload-params
env:
PLATFORM_ARTIFACT_MARKER: ${{ matrix.plan.platform.artifactMarker }}
run: |
EXECUTABLE_PATH="target/release/humanode-peer"
ARTIFACT_NAME="humanode-peer-$(rustc -vV | sed -n 's|host: ||p')"
if [[ "$PLATFORM_ARTIFACT_MARKER" != "" ]]; then
ARTIFACT_NAME="${ARTIFACT_NAME}-${PLATFORM_ARTIFACT_MARKER}"
fi
if [[ "${PATHEXT:-""}" != "" ]]; then
EXECUTABLE_PATH="${EXECUTABLE_PATH}.exe"
fi
printf 'executable-path=%s\n' "$EXECUTABLE_PATH" >> "$GITHUB_OUTPUT"
printf 'artifact-name=%s\n' "$ARTIFACT_NAME" >> "$GITHUB_OUTPUT"
printf 'Packaged `%s` into `%s`.\n' \
"$EXECUTABLE_PATH" \
"$ARTIFACT_NAME" \
>> "$GITHUB_STEP_SUMMARY"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.set-upload-params.outputs.artifact-name }}
path: ${{ steps.set-upload-params.outputs.executable-path }}
if-no-files-found: error
retention-days: 5
- name: Archive the binary for release
if: startsWith(github.ref, 'refs/tags/')
env:
EXECUTABLE_NAME: ${{ steps.set-upload-params.outputs.executable-path }}
run: utils/make-release-archive "$EXECUTABLE_NAME" archive.tar.gz
- name: Upload release archive
uses: shogo82148/actions-upload-release-asset@v1
if: startsWith(github.ref, 'refs/tags/')
with:
upload_url: ${{ needs.draft-release.outputs.upload-url }}
asset_name: ${{ steps.set-upload-params.outputs.artifact-name }}.tar.gz
asset_path: archive.tar.gz
publish-release:
needs:
- draft-release
- build
name: Publish release
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-22.04
timeout-minutes: 50
permissions:
contents: write
steps:
- name: Publish release
uses: actions/github-script@v7
env:
RELEASE_ID: ${{ needs.draft-release.outputs.release-id }}
with:
script: |
github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.RELEASE_ID,
draft: false
});