Skip to content

Commit b444eb2

Browse files
committed
ci: modernize pipeline
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent fdd817f commit b444eb2

File tree

3 files changed

+87
-15
lines changed

3 files changed

+87
-15
lines changed

.github/workflows/wit-deps.yml

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ jobs:
1616
config:
1717
- target: aarch64-unknown-linux-musl
1818
install-path: /bin/wit-deps
19-
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-aarch64 ./result/bin/wit-deps --version
19+
test-bin: |
20+
nix profile install --inputs-from . 'nixpkgs-unstable#qemu'
21+
qemu-aarch64 ./result/bin/wit-deps --version
2022
test-oci: docker load < ./result
2123
# TODO: Run aarch64 binary within OCI
2224

@@ -27,7 +29,9 @@ jobs:
2729

2830
- target: armv7-unknown-linux-musleabihf
2931
install-path: /bin/wit-deps
30-
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-arm ./result/bin/wit-deps --version
32+
test-bin: |
33+
nix profile install --inputs-from . 'nixpkgs-unstable#qemu'
34+
qemu-arm ./result/bin/wit-deps --version
3135
test-oci: docker load < ./result
3236
# TODO: Run armv7 binary within OCI
3337

@@ -38,7 +42,9 @@ jobs:
3842

3943
- target: x86_64-pc-windows-gnu
4044
install-path: /bin/wit-deps.exe
41-
test-bin: nix shell --inputs-from . 'nixpkgs#wine64' -c wine64 ./result/bin/wit-deps.exe --version
45+
test-bin: |
46+
nix profile install --inputs-from . 'nixpkgs-unstable#wine64'
47+
wine64 ./result/bin/wit-deps.exe --version
4248
test-oci: docker load < ./result
4349
# TODO: Run windows binary within OCI
4450

@@ -146,30 +152,78 @@ jobs:
146152
id: deployment
147153

148154
oci:
149-
runs-on: ubuntu-22.04
155+
runs-on: ubuntu-24.04
150156
if: ${{ github.event_name != 'pull_request' }}
151157
needs: build-bin
152158
permissions:
153159
packages: write
154160
steps:
155-
- uses: actions/checkout@v5
161+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
156162
- uses: ./.github/actions/install-nix
157163
with:
158164
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
159-
- uses: docker/login-action@v3
165+
166+
- name: Extract tag context
167+
id: ctx
168+
run: |
169+
echo "owner=${GITHUB_REPOSITORY_OWNER,,}" >> "$GITHUB_OUTPUT"
170+
echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
171+
172+
version=${GITHUB_REF_NAME#v}
173+
echo "version=${version}" >> "$GITHUB_OUTPUT"
174+
echo "version is ${version}"
175+
if [[ $version == *"-"* ]]; then
176+
echo "version ${version} is a pre-release"
177+
echo "prerelease=true" >> "$GITHUB_OUTPUT"
178+
fi
179+
180+
- name: Login to GitHub Container Registry
181+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
160182
with:
161183
registry: ghcr.io
162184
username: ${{ github.repository_owner }}
163185
password: ${{ secrets.GITHUB_TOKEN }}
164-
- run: |
165-
nix run -L .#build-wit-deps-oci wit-deps
166-
nix profile install --inputs-from . 'nixpkgs#buildah'
167-
buildah manifest push --all --format 'v2s2' wit-deps docker://ghcr.io/${{ github.repository_owner }}/wit-deps:${{ github.sha }}
168-
docker run ghcr.io/${{ github.repository_owner }}/wit-deps:${{ github.sha }} wit-deps --version
186+
187+
- name: Install `skopeo`
188+
run: nix profile install --inputs-from . 'nixpkgs-unstable#skopeo'
189+
190+
- name: Build image
191+
run: nix build -L .#wit-deps-oci
192+
193+
- name: Test image
194+
run: |
195+
skopeo copy oci-archive:./result docker-daemon:wit-deps:test
196+
docker run --rm wit-deps:test wit-deps --version
197+
198+
- name: Push commit rev tag
199+
if: startswith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'
200+
run: |
201+
skopeo copy --all oci-archive:./result docker://ghcr.io/${{ steps.ctx.outputs.owner }}/wit-deps:${{ github.sha }}
202+
skopeo copy --all oci-archive:./result docker://ghcr.io/${{ steps.ctx.outputs.owner }}/wit-deps:${{ steps.ctx.outputs.sha_short }}
203+
204+
docker run --rm ghcr.io/${{ steps.ctx.outputs.owner }}/wit-deps:${{ github.sha }} wit-deps --version
205+
docker run --rm ghcr.io/${{ steps.ctx.outputs.owner }}/wit-deps:${{ steps.ctx.outputs.sha_short }} wit-deps --version
206+
207+
- name: Push version tag
208+
if: startswith(github.ref, 'refs/tags/v')
209+
run: |
210+
skopeo copy --all oci-archive:./result docker://ghcr.io/${{ steps.ctx.outputs.owner }}/wit-deps:${{ steps.ctx.outputs.version }}
211+
docker run --rm ghcr.io/${{ steps.ctx.outputs.owner }}/wit-deps:${{ steps.ctx.outputs.version }} wit-deps --version
212+
213+
- name: Push `latest` tag
214+
if: startswith(github.ref, 'refs/tags/v') && !steps.ctx.outputs.prerelease
215+
run: |
216+
skopeo copy --all oci-archive:./result docker://ghcr.io/${{ steps.ctx.outputs.owner }}/wit-deps:latest
217+
docker run --rm ghcr.io/${{ steps.ctx.outputs.owner }}/wit-deps:latest wit-deps --version
169218
170219
release:
171-
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push'
172-
needs: [ build-bin, build-lipo, build-doc, cargo ]
220+
if: startsWith(github.ref, 'refs/tags/v')
221+
needs:
222+
- build-bin
223+
- build-doc
224+
- build-lipo
225+
- cargo
226+
- oci
173227
runs-on: ubuntu-24.04
174228
permissions:
175229
contents: write
@@ -218,7 +272,7 @@ jobs:
218272
with:
219273
name: wit-deps-x86_64-unknown-linux-musl-oci
220274

221-
- uses: softprops/action-gh-release@v2
275+
- uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1
222276
with:
223277
draft: true
224278
prerelease: true

flake.lock

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
inputs.nixify.inputs.nixlib.follows = "nixlib";
2929
inputs.nixify.url = "github:rvolosatovs/nixify";
3030
inputs.nixlib.url = "github:nix-community/nixpkgs.lib";
31+
inputs.nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
3132

3233
outputs = {
3334
self,

0 commit comments

Comments
 (0)