-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from yfyf/backport-release-disk-2024.7.0
Backport release disk to 2024.7.0
- Loading branch information
Showing
10 changed files
with
222 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
RELEASE_TAG="$1" | ||
|
||
# Find the previous "proper" release (i.e. not VALIDATION) tag. | ||
# Note: `--version-sort` incorrectly sorts semver pre-releases, but | ||
# these get filtered out later, so it does not matter. | ||
prev_tag="$(git tag \ | ||
| sort --version-sort \ | ||
| grep -B10000 "$RELEASE_TAG" \ | ||
| grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' \ | ||
| head -n -1 \ | ||
| tail -1)" || echo "" | ||
|
||
if [[ -z "$prev_tag" ]]; then | ||
echo "Error: failed to determine previous release tag, are you sure input tag $RELEASE_TAG exists?" | ||
exit 1 | ||
else | ||
echo "Previous proper release tag is: $prev_tag" >&2 | ||
fi | ||
|
||
echo -e " | ||
# Release $RELEASE_TAG | ||
## Artifacts | ||
- Test disk: [https://dividat-playos-test-disks.s3.amazonaws.com/by-tag/playos-release-disk-$RELEASE_TAG.img.zst](https://dividat-playos-test-disks.s3.amazonaws.com/by-tag/playos-release-disk-$RELEASE_TAG.img.zst) | ||
## Changelog | ||
" | ||
|
||
# print changelog since $prev_tag (exclusive) | ||
grep -E -B10000 "^# \[$prev_tag\]" ./Changelog.md \ | ||
| head -n -1 \ | ||
| sed -E 's/#+/\0##/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Release Tag | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
|
||
- name: Ensure KVM is usable by nix-build | ||
run: sudo chmod a+rwx /dev/kvm | ||
shell: bash | ||
- uses: cachix/install-nix-action@v18 | ||
with: | ||
nix_path: nixpkgs=channel:nixos-unstable | ||
extra_nix_config: | | ||
system-features = nixos-test benchmark big-parallel kvm | ||
- uses: DeterminateSystems/magic-nix-cache-action@v8 | ||
|
||
- name: Make magic-nix-cache read-only by removing post-build-hook | ||
run: sed -i '/post-build-hook = magic-nix-cache-build-hook/d' $HOME/.config/nix/nix.conf | ||
|
||
- name: Validate tag | ||
run: | | ||
app_vsn="$(nix eval --raw -f application.nix 'version')" | ||
if [ "$app_vsn" != "$GITHUB_REF_NAME" ]; then | ||
echo "Git tag ($GITHUB_REF_NAME) does not match version in application.nix ($app_vsn), aborting!" | ||
exit 1 | ||
fi | ||
- name: Build release disk | ||
run: ./build release-disk | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v3 | ||
with: | ||
aws-access-key-id: ${{ secrets.TEST_DISKS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.TEST_DISKS_SECRET_ACCESS_KEY }} | ||
aws-region: eu-central-1 | ||
|
||
- name: Publish to S3 | ||
run: ./.github/workflows/upload-test-disk.sh "$GITHUB_REF_NAME" | ||
|
||
- name: Create Release summary | ||
run: ./.github/workflows/gen-release-summary.sh "$GITHUB_REF_NAME" > ./release-notes.md | ||
|
||
- name: Create Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
extra_args="" | ||
if [[ "$GITHUB_REF_NAME" == *VALIDATION ]]; then | ||
extra_args="--prerelease" | ||
elif [[ "$GITHUB_REF_NAME" == *TEST ]]; then | ||
extra_args="--draft" | ||
fi | ||
gh release create --verify-tag \ | ||
-F ./release-notes.md \ | ||
$extra_args \ | ||
"$GITHUB_REF_NAME" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
RELEASE_TAG="$1" | ||
|
||
set -euo pipefail | ||
set -x | ||
disk_path="$(readlink ./result/playos-release-disk-$RELEASE_TAG.img.zst)" | ||
target_url="s3://dividat-playos-test-disks/by-tag/playos-release-disk-$RELEASE_TAG.img.zst" | ||
echo "Uploading test disk to: $target_url" | ||
aws s3 cp "$disk_path" "$target_url" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Similarly to testing/disk/default.nix, this builds a disk image containing | ||
# a full PlayOS installation, with these differences: | ||
# - It uses default system and boot partition sizes. Total disk size is ~20 GiB | ||
# - It produces a (sparsified) qcow2 image rather than a raw one. This reduces | ||
# the image size to ~8GiB | ||
# - It compresses the final image using zstd to reduce disk usage. | ||
# Final compressed file size is around ~4GiB. | ||
{ pkgs | ||
, lib | ||
, install-playos | ||
}: | ||
with pkgs; | ||
with lib; | ||
let | ||
# all sizes in MiB | ||
partSizes = { | ||
boot = 525; # 525 MiB (matches install-playos default) | ||
system = 1024 * 9; # 9 GiB (install-playos default - 1GiB) | ||
data = 400; # 400 MiB (same as testing/disk/default.nix) | ||
}; | ||
diskSizeMiB = 8 + partSizes."boot" + partSizes."data" + (partSizes."system" * 2) + 1; | ||
in | ||
vmTools.runInLinuxVM ( | ||
runCommand "build-playos-release-disk" | ||
{ | ||
buildInputs = [install-playos]; | ||
|
||
preVM = '' | ||
diskImage=nixos.raw | ||
truncate -s ${toString diskSizeMiB}MiB $diskImage | ||
''; | ||
|
||
postVM = '' | ||
mkdir -p $out | ||
${pkgs.qemu}/bin/qemu-img convert -f raw -O qcow2 $diskImage $out/playos-disk.img | ||
rm $diskImage | ||
${pkgs.zstd}/bin/zstd --rm -f $out/playos-disk.img -o $out/playos-disk.img.zst | ||
diskImage=$out/playos-disk.img.zst | ||
''; | ||
memSize = 1024; | ||
} | ||
'' | ||
# machine-id of development image is hardcoded. | ||
install-playos \ | ||
--device /dev/vda \ | ||
--machine-id "f414cca8312548d29689ebf287fb67e0" \ | ||
--no-confirm | ||
'' | ||
) + "/playos-disk.img.zst" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
users.users.root.initialHashedPassword = ""; | ||
} |