Skip to content

New release workflow #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
48ca339
Add new release workflow
arianvp Apr 12, 2025
ba01bac
Add new release workflow
arianvp Apr 12, 2025
355406d
Fix permissions
arianvp Apr 12, 2025
3613988
Actually add images to flake
arianvp Apr 12, 2025
4524567
Add concurrency
arianvp Apr 12, 2025
a600ab0
Fix names
arianvp Apr 12, 2025
9939493
Fix download. And only attest on main
arianvp Apr 12, 2025
bee4faf
Fix concurrency
arianvp Apr 12, 2025
4000ddd
Add debug info
arianvp Apr 12, 2025
58628a1
use github artifacts as a cache
arianvp Apr 12, 2025
cd6e402
Fix syntax error
arianvp Apr 12, 2025
e78501d
Fix typo
arianvp Apr 12, 2025
9858600
Fix flake-ref
arianvp Apr 12, 2025
1953c6b
debutg
arianvp Apr 12, 2025
78e2ee5
Fix it
arianvp Apr 12, 2025
3795403
Always attest. as we might have a cached artifact from a pull request
arianvp Apr 12, 2025
f5a801c
Tweak
arianvp Apr 12, 2025
b3ca20e
Attest what image ids we uploaded
arianvp Apr 12, 2025
f81fb01
Fix syntax error
arianvp Apr 12, 2025
7efac08
Add images environment
arianvp Apr 12, 2025
308172f
Fix typo
arianvp Apr 12, 2025
38be766
Fix provenance
arianvp Apr 12, 2025
4fc9751
Add predicate accountId
arianvp Apr 12, 2025
171589e
hack around fact that download-artifact is not in nix store. Should f…
arianvp Apr 12, 2025
7f3003f
Fix
arianvp Apr 12, 2025
eff83fd
fix multi-line
arianvp Apr 12, 2025
30c1965
Try again
arianvp Apr 12, 2025
19af74f
Fix
arianvp Apr 12, 2025
dcf52bd
one last try with attesting the image ids
arianvp Apr 12, 2025
ac17880
ignore the flake interface of nixpkgs as it's utterly broken
arianvp Apr 13, 2025
8409307
lock flake
arianvp Apr 22, 2025
086fde0
Change custom predicate type
arianvp Apr 22, 2025
883ee37
implement actual upload
arianvp Apr 22, 2025
d8eec36
Hello ci?
arianvp Apr 22, 2025
7997172
latest github action
arianvp Apr 22, 2025
cde3c07
Complete release.yml
arianvp Apr 23, 2025
08757bf
Re-enable arm
arianvp Apr 23, 2025
51632eb
Fix jq syntax
arianvp Apr 23, 2025
90309b4
Try to make github actions matrix prettier in UI
arianvp Apr 23, 2025
826726a
more prettification
arianvp Apr 23, 2025
fb010bb
Bikeshed name so the GitHub UI doesn't look bad
arianvp Apr 23, 2025
9288f39
Track AMIs in separate flake so we only run the job when the channel …
arianvp Apr 23, 2025
80258f9
fmt upload-ami
arianvp Apr 23, 2025
d359a74
new workflow only on unstable for now
arianvp Apr 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .github/workflows/build-and-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Build and upload AMI
on:
workflow_call:
inputs:
system:
type: string
runs-on:
type: string
release:
type: string
jobs:
build:
name: Build
runs-on: ${{ inputs.runs-on }}
permissions:
contents: read
id-token: write
attestations: write
outputs:
name: ${{ steps.build.outputs.name }}
digest: ${{ steps.upload-artifact.outputs.artifact-digest }}
env:
flakeref: .?dir=amis#hydraJobs.${{ inputs.release }}.amazonImage.${{ inputs.system }}
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d # v16
with:
# HACK: lets lie that we support kvm. make-disk-image.nix is fast enough in emulation mode
# and aarch64 has no kvm on github actions
extra-conf: extra-system-features = kvm
- run: |
out=$(nix build -L "$flakeref" --print-out-paths)
echo "out=$out" >> "$GITHUB_OUTPUT"
echo "name=$(basename "$out")" >> "$GITHUB_OUTPUT"
id: build
env:
flakeref: .#hydraJobs.${{ inputs.release }}.amazonImage.${{ inputs.system }}
- uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
id: upload-artifact
with:
name: ${{ steps.build.outputs.name }}
path: ${{ steps.build.outputs.out }}
# TODO: use https://github.com/arianvp/nix-attest to store more provenance information
- uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
if: github.ref == 'refs/heads/main'
with:
subject-name: ${{ steps.build.outputs.name }}
subject-digest: sha256:${{ steps.upload-artifact.outputs.artifact-digest }}
upload:
name: Upload
runs-on: ubuntu-latest
needs: [build]
environment: images
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
id: download-artifact
with:
name: ${{ needs.build.outputs.name }}
path: ./result
- uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d # v16
- uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
with:
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/upload-ami
aws-region: ${{ vars.AWS_REGION }}

- name: Upload smoke test
id: upload-smoke-test
run: |
predicate=$(nix run .#upload-ami -- --image-info "$image_info" --prefix "nixos/" --s3-bucket "$images_bucket")
echo "predicate=$predicate" >> "$GITHUB_OUTPUT"
env:
image_info: ./result/nix-support/image-info.json
images_bucket: ${{ vars.IMAGES_BUCKET }}

- name: Run smoke test
id: smoke-test
run: nix run .#smoke-test -- --image-id "$image_id"
env:
image_id: ${{ fromJson(steps.upload-smoke-test.outputs.predicate).image_ids[vars.AWS_REGION] }}

- name: Clean up smoke test
if: ${{ cancelled() }}
run: |
image_id=$(echo "$image_ids" | jq -r '.[$ENV.AWS_REGION]')
nix run .#smoke-test -- --image-id "$image_id" --cancel
env:
image_ids: ${{ steps.upload-smoke-test.outputs.image_ids }}

- name: Upload AMIs to all available regions
if: github.ref == 'refs/heads/main'
id: upload-amis
run: |
predicate=$(nix run .#upload-ami -- \
--image-info "$image_info" \
--prefix "nixos/" \
--s3-bucket "$images_bucket" \
--copy-to-regions \
--public)
echo "predicate=$predicate" >> "GITHUB_OUTPUT"
env:
image_info: ./result/nix-support/image-info.json
images_bucket: ${{ vars.IMAGES_BUCKET }}

# TODO: Only create if something was *actually* uploaded
- name: Create upload attestation
uses: actions/attest@a63cfcc7d1aab266ee064c58250cfc2c7d07bc31 # v2.1.1
if: github.ref == 'refs/heads/main'
with:
subject-name: ${{ needs.build.outputs.name }}
subject-digest: sha256:${{ needs.build.outputs.digest }}
predicate-type: "https://github.com/NixOS/amis/predicates/upload-ami/v0"
predicate: ${{ steps.upload-amis.outputs.predicate }}
83 changes: 83 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build and upload AMIs
on:
pull_request:
paths:
- amis/**
push:
branches:
- main
paths:
- amis/**
jobs:
build-and-upload:
name: ${{ matrix.release }} ${{ matrix.system.system }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.release }}-${{ matrix.system.runs-on }}-${{ matrix.system.system }}
cancel-in-progress: true
permissions:
id-token: write
attestations: write
contents: read
strategy:
fail-fast: false
matrix:
release:
# - nixos_2411
- nixos_unstable
system:
- runs-on: ubuntu-latest
system: x86_64-linux
- runs-on: ubuntu-24.04-arm
system: aarch64-linux
uses: ./.github/workflows/build-and-upload.yml
with:
runs-on: ${{ matrix.system.runs-on }}
system: ${{ matrix.system.system }}
release: ${{ matrix.release }}
delete-deprecated-images:
name: Delete deprecated images
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build-and-upload
environment: images
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d # v16
- uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
with:
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/upload-ami
aws-region: ${{ vars.AWS_REGION }}
- name: Delete deprecated AMIs
if: github.ref == 'refs/heads/main'
run: "nix run .#delete-deprecated-images"
deploy-pages:
name: Deploy images page
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: [build-and-upload, delete-deprecated-images]
permissions:
contents: read
id-token: write
pages: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d # v16
- uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
with:
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/github-pages
aws-region: ${{ vars.AWS_REGION }}
- name: Describe images
run: nix run .#describe-images > ./site/images.json
- name: Upload pages
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
path: ./site
- name: Deploy pages
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
id: deployment
131 changes: 0 additions & 131 deletions .github/workflows/upload-legacy-ami.yml

This file was deleted.

40 changes: 40 additions & 0 deletions amis/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading