-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (179 loc) · 7.75 KB
/
Copy pathrelease.yml
File metadata and controls
186 lines (179 loc) · 7.75 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: build-test-release
# DFTools per-image release pipeline, independent of the DFHDL library release.
#
# detect (which images changed)
# -> build-test (only affected images x arch; per-image self-test)
# -> dfhdl-gate (DFHDL latest release + main, against the freshly built images)
# -> publish (only on a version tag or manual dispatch, and only if the gate passed)
#
# Bumping a pin in pins.env rebuilds only the image(s) that contain that tool.
on:
push:
branches: [ main ]
paths: [ 'pins.env', 'images/**', 'build/**', 'scripts/**', '.github/workflows/release.yml' ]
tags: [ 'v*' ]
workflow_dispatch:
inputs:
images:
description: 'Space-separated images to build (empty = all)'
required: false
publish:
description: 'Publish a release from this run'
type: boolean
default: false
version:
description: 'Release version tag (e.g. v0.1.0); required when publish=true'
required: false
permissions:
contents: write
jobs:
detect:
runs-on: ubuntu-24.04
outputs:
images: ${{ steps.set.outputs.images }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- id: set
run: |
set -euo pipefail
if [ -n "${{ github.event.inputs.images }}" ]; then
list="${{ github.event.inputs.images }}"
elif [ "${{ github.event_name }}" = "workflow_dispatch" ] || [ "${{ github.ref_type }}" = "tag" ]; then
list="$(sh scripts/affected-images.sh)" # all
else
list="$(sh scripts/affected-images.sh '${{ github.event.before }}' '${{ github.sha }}')"
fi
json=$(printf '%s\n' $list | jq -R . | jq -cs .)
echo "images=$json" >> "$GITHUB_OUTPUT"
echo "affected images: $list"
build-test:
needs: detect
if: needs.detect.outputs.images != '[]'
strategy:
fail-fast: true
matrix:
image: ${{ fromJson(needs.detect.outputs.images) }}
arch: [ linux-x64, linux-arm64 ]
include:
- arch: linux-x64
runs-on: ubuntu-24.04
- arch: linux-arm64
runs-on: ubuntu-24.04-arm
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v7
- name: Free up disk space
uses: jlumbroso/free-disk-space@main
with: { tool-cache: true, large-packages: true, docker-images: true }
# Official upstream PPA — covers both amd64 and arm64 on noble and tracks the
# current 1.5.x (matches what we build/run with locally). The setup-apptainer
# action only ships an amd64 .deb and fails on the arm64 runner.
- name: Setup Apptainer
run: |
set -eux
sudo add-apt-repository -y ppa:apptainer/ppa
sudo apt-get update
sudo apt-get install -y apptainer
apptainer --version
- name: Setup JDK + Scala CLI
uses: VirtusLab/scala-cli-setup@v1
with: { jvm: 'temurin:21' }
- name: Build image
run: |
set -euo pipefail
scala-cli run scripts/build.sc -- ${{ matrix.image }} dftools-${{ matrix.image }}-${{ matrix.arch }}.sif
sha256sum dftools-${{ matrix.image }}-${{ matrix.arch }}.sif > dftools-${{ matrix.image }}-${{ matrix.arch }}.sif.sha256
- name: Probe image
run: scala-cli run scripts/test.sc -- probe ${{ matrix.image }} dftools-${{ matrix.image }}-${{ matrix.arch }}.sif
- uses: actions/upload-artifact@v7
with:
name: dftools-${{ matrix.image }}-${{ matrix.arch }}
path: |
dftools-${{ matrix.image }}-${{ matrix.arch }}.sif
dftools-${{ matrix.image }}-${{ matrix.arch }}.sif.sha256
dftools-${{ matrix.image }}-${{ matrix.arch }}.MANIFEST.txt
retention-days: 7
dfhdl-gate:
needs: build-test
strategy:
matrix:
arch: [ linux-x64, linux-arm64 ]
include:
- arch: linux-x64
runs-on: ubuntu-24.04
- arch: linux-arm64
runs-on: ubuntu-24.04-arm
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v7
# Official upstream PPA — covers both amd64 and arm64 on noble and tracks the
# current 1.5.x (matches what we build/run with locally). The setup-apptainer
# action only ships an amd64 .deb and fails on the arm64 runner.
- name: Setup Apptainer
run: |
set -eux
sudo add-apt-repository -y ppa:apptainer/ppa
sudo apt-get update
sudo apt-get install -y apptainer
apptainer --version
# DFHDL builds on JDK 17 with sbt + bloop (see dfhdl/.github/workflows/build.yml).
# scala-cli is added only to run this repo's gate driver (scripts/test.sc), which
# then invokes `sbt testApps` inside the DFHDL checkout on the same JAVA_HOME.
- name: Setup Scala
uses: coursier/setup-action@v3
with:
jvm: temurin:1.17.0.14
apps: sbt bloop scala-cli
- name: Download freshly built images (this arch)
uses: actions/download-artifact@v8
with:
pattern: dftools-*-${{ matrix.arch }}
path: dist
merge-multiple: true
# TEMPORARY: while the DFHDL DFTools integration lives on the `dftools` branch, gate
# only against that branch. Restore the latest-release + main gate once it is merged.
- name: Check out DFHDL (dftools branch)
run: git clone --branch dftools --depth 1 https://github.com/DFiantHDL/dfhdl.git dfhdl-dftools
# Sifs are named dftools-<image>-<arch>.sif; test.sc maps each to the per-image override.
# Images not rebuilt in this run fall back to DFHDL's published-release resolution.
- name: Gate against DFHDL dftools branch
run: scala-cli run scripts/test.sc -- dfhdl dist dfhdl-dftools
publish:
# TEMPORARY: the DFHDL gate is decoupled from publishing while we iron out gate issues,
# so freshly built images can be released and used to debug. Publish depends only on a
# successful build-test; the dfhdl-gate still runs for visibility but does not block.
# Restore `needs: dfhdl-gate` once the gate is green.
needs: build-test
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && inputs.publish)
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with: { path: dist, merge-multiple: true }
- id: ver
run: |
if [ "${{ github.ref_type }}" = "tag" ]; then echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT";
else echo "tag=${{ inputs.version }}" >> "$GITHUB_OUTPUT"; fi
- name: Setup JDK + Scala CLI
uses: VirtusLab/scala-cli-setup@v1
with: { jvm: 'temurin:21' }
# Rename the built sifs to immutable, content-addressed asset names and (re)generate the
# lockfile mapping each image+arch to its sha256 + asset. Seeded from the prior lockfile on
# the tag, so a partial re-publish carries unchanged images forward.
- name: Build lockfile + immutable asset names
run: scala-cli run scripts/lockfile.sc -- ${{ steps.ver.outputs.tag }} dist
# Attach the immutable per-image sifs + the lockfile to the release tag. Immutable names never
# collide across builds, so previously published assets on the same tag are left intact; the
# lockfile (stable name) is overwritten to point at the current digest set.
- name: Publish image assets to release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.ver.outputs.tag }}
name: DFTools ${{ steps.ver.outputs.tag }}
files: |
dist/*.sif
dist/*.sif.sha256
dist/*.MANIFEST.txt
dist/dftools.lock.json