-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (166 loc) · 5.95 KB
/
Copy pathplugin-dist.yml
File metadata and controls
186 lines (166 loc) · 5.95 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
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
name: plugin-dist
on:
push:
branches:
- main
tags:
- '*'
workflow_dispatch:
jobs:
detect:
name: Detect changed plugins
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.packages.outputs.packages }}
has-packages: ${{ steps.packages.outputs.has-packages }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine base revision
id: base
env:
EVENT_NAME: ${{ github.event_name }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PUSH_BEFORE: ${{ github.event.before }}
run: |
set -euo pipefail
NULL_SHA=0000000000000000000000000000000000000000
if [ "$EVENT_NAME" = "pull_request" ] && [ -n "$PR_BASE_SHA" ]; then
BASE_SHA="$PR_BASE_SHA"
elif [ -n "$PUSH_BEFORE" ] && [ "$PUSH_BEFORE" != "$NULL_SHA" ]; then
BASE_SHA="$PUSH_BEFORE"
elif git rev-parse HEAD^ >/dev/null 2>&1; then
BASE_SHA="$(git rev-parse HEAD^)"
else
BASE_SHA=""
fi
echo "Base revision: ${BASE_SHA:-<none>}"
echo "sha=$BASE_SHA" >> "$GITHUB_OUTPUT"
shell: bash
- name: Determine packages requiring build
id: packages
env:
BASE_SHA: ${{ steps.base.outputs.sha }}
run: python3 .github/scripts/detect_changed_plugins.py
shell: bash
dist:
name: Build ${{ matrix.package }} @ ${{ matrix.target }}
needs: detect
if: needs.detect.outputs.has-packages == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.detect.outputs.packages) }}
target:
- x86_64-unknown-linux-gnu
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-pc-windows-msvc
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-14
- target: x86_64-pc-windows-msvc
os: windows-latest
env:
PACKAGE: ${{ matrix.package }}
DIST_TARGET: ${{ matrix.target }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install Cap'n Proto (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y capnproto
- name: Install Rust targets (Linux)
if: runner.os == 'Linux'
run: |
rustup target add x86_64-unknown-linux-gnu
- name: Install Cap'n Proto (macOS)
if: runner.os == 'macOS'
run: brew install capnp
- name: Install Rust targets (macOS)
if: runner.os == 'macOS'
run: |
rustup target add x86_64-apple-darwin aarch64-apple-darwin
- name: Install Cap'n Proto (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: choco install capnproto --yes
- name: Install Rust targets (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
rustup target add x86_64-pc-windows-msvc
- name: Cache cargo build artefacts
uses: Swatinem/rust-cache@v2
- name: Resolve package version
id: package-version
env:
PACKAGE: ${{ matrix.package }}
run: python3 .github/scripts/get_package_version.py --package "$PACKAGE"
shell: bash
- name: Build release binary
run: |
set -euo pipefail
cargo build -p "$PACKAGE" --release --target "$DIST_TARGET"
shell: bash
- name: Package release archive
id: package-archive
env:
VERSION: ${{ steps.package-version.outputs.version }}
run: |
set -euo pipefail
ARCHIVE_NAME=$(python3 .github/scripts/package_archive.py \
--package "$PACKAGE" \
--version "$VERSION" \
--target "$DIST_TARGET" \
--release-dir "target/$DIST_TARGET/release" \
--output-dir "target/artifacts")
echo "archive_name=$ARCHIVE_NAME" >> "$GITHUB_OUTPUT"
echo "ARCHIVE_NAME=$ARCHIVE_NAME" >> "$GITHUB_ENV"
shell: bash
- name: Upload dist artefacts
id: upload
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.package }}-${{ steps.package-version.outputs.version }}-${{ matrix.target }}
path: target/artifacts/${{ env.ARCHIVE_NAME }}
if-no-files-found: error
- name: Record artifact location
if: success()
env:
VERSION: ${{ steps.package-version.outputs.version }}
ARCHIVE_NAME: ${{ env.ARCHIVE_NAME }}
ARTIFACT_ID: ${{ steps.upload.outputs.artifact-id }}
ARTIFACT_API_URL: ${{ steps.upload.outputs.artifact-url }}
REPOSITORY: ${{ github.repository }}
RUN_ID: ${{ github.run_id }}
REF_NAME: ${{ github.ref_name }}
REF_TYPE: ${{ github.ref_type }}
run: |
set -euo pipefail
MESSAGE="Artifact ${PACKAGE} (${DIST_TARGET}) uploaded: ${ARTIFACT_API_URL}"
echo "::notice::${MESSAGE}"
RELEASE_TAG="$REF_NAME"
if [ "$REF_TYPE" != "tag" ] || [ -z "$RELEASE_TAG" ]; then
RELEASE_TAG="${PACKAGE}-v${VERSION}"
fi
RELEASE_URL="https://github.com/${REPOSITORY}/releases/download/${RELEASE_TAG}/${ARCHIVE_NAME}"
{
echo "### ${PACKAGE} v${VERSION} (${DIST_TARGET})"
echo ""
echo "- Artifact URL: ${ARTIFACT_API_URL}"
echo "- Release download (expected): ${RELEASE_URL}"
echo "- Artifact ID: ${ARTIFACT_ID}"
echo "- Workflow run: https://github.com/${REPOSITORY}/actions/runs/${RUN_ID}"
echo ""
} >> "$GITHUB_STEP_SUMMARY"
shell: bash