110 lines
4.8 KiB
YAML
110 lines
4.8 KiB
YAML
name: Test NaxOS Module Configurations
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
jobs:
|
|
test-modules:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Nix
|
|
uses: cachix/install-nix-action@v27
|
|
with:
|
|
extra_nix_config: |
|
|
experimental-features = nix-command flakes
|
|
|
|
- name: Evaluate Flake Outputs & Check Syntax
|
|
run: |
|
|
nix flake show
|
|
nix eval .#nixosConfigurations.naxos.config.system.build.toplevel.drvPath
|
|
nix eval .#nixosConfigurations.installer-iso.config.system.build.isoImage.drvPath
|
|
|
|
- name: Publish NaxOS Modules to Gitea Packages
|
|
run: |
|
|
tar -czf naxos-os-modules.tar.gz modules profiles iso flake.nix flake.lock
|
|
echo "Packaging naxos-os-modules.tar.gz to Gitea Packages registry..."
|
|
TOKEN="${{ secrets.PACKAGE_TOKEN }}"
|
|
if [ -z "$TOKEN" ]; then
|
|
TOKEN="${{ secrets.GITEA_TOKEN }}"
|
|
fi
|
|
RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}" -X PUT \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
--upload-file naxos-os-modules.tar.gz \
|
|
"${{ github.server_url }}/api/packages/naxos/generic/naxos-os-modules/1.0.0/naxos-os-modules.tar.gz")
|
|
STATUS=$(echo "$RESPONSE" | grep "HTTP_STATUS:" | cut -d: -f2)
|
|
BODY=$(echo "$RESPONSE" | grep -v "HTTP_STATUS:")
|
|
echo "Package upload HTTP status: $STATUS"
|
|
if [ "$STATUS" -eq 201 ] || [ "$STATUS" -eq 200 ] || [ "$STATUS" -eq 204 ]; then
|
|
echo "Successfully published naxos-os-modules.tar.gz to Gitea Packages!"
|
|
elif [ "$STATUS" -eq 409 ]; then
|
|
echo "Package version 1.0.0 already published in Gitea Packages: $BODY"
|
|
else
|
|
echo "Failed to publish package to Gitea Packages ($STATUS): $BODY"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Build & Publish Bootable Installer ISO
|
|
run: |
|
|
echo "Building NaxOS Bootable Installer ISO..."
|
|
nix build .#iso --option max-jobs auto
|
|
ISO_FILE=$(ls result/iso/*.iso | head -n 1)
|
|
echo "Built ISO image: $ISO_FILE ($(du -h "$ISO_FILE" | cut -f1))"
|
|
sha256sum "$ISO_FILE" > "$ISO_FILE.sha256"
|
|
|
|
TOKEN="${{ secrets.PACKAGE_TOKEN }}"
|
|
if [ -z "$TOKEN" ]; then
|
|
TOKEN="${{ secrets.GITEA_TOKEN }}"
|
|
fi
|
|
|
|
ISO_NAME=$(basename "$ISO_FILE")
|
|
echo "Publishing $ISO_NAME and naxos-installer-x86_64-linux.iso to Gitea Packages..."
|
|
|
|
# Publish canonical ISO name requested by users
|
|
curl -s -X PUT \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
--upload-file "$ISO_FILE" \
|
|
"${{ github.server_url }}/api/packages/naxos/generic/naxos-installer-iso/1.0.0/naxos-installer-x86_64-linux.iso" || echo "Canonical ISO already exists"
|
|
|
|
curl -s -X PUT \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
--upload-file "$ISO_FILE.sha256" \
|
|
"${{ github.server_url }}/api/packages/naxos/generic/naxos-installer-iso/1.0.0/naxos-installer-x86_64-linux.iso.sha256" || echo "Canonical Checksum already exists"
|
|
|
|
# Publish versioned Nix-generated filename
|
|
curl -s -X PUT \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
--upload-file "$ISO_FILE" \
|
|
"${{ github.server_url }}/api/packages/naxos/generic/naxos-installer-iso/1.0.0/$ISO_NAME" || echo "ISO package already exists"
|
|
|
|
curl -s -X PUT \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
--upload-file "$ISO_FILE.sha256" \
|
|
"${{ github.server_url }}/api/packages/naxos/generic/naxos-installer-iso/1.0.0/$ISO_NAME.sha256" || echo "Checksum already exists"
|
|
|
|
# Publish latest channel
|
|
curl -s -X PUT \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
--upload-file "$ISO_FILE" \
|
|
"${{ github.server_url }}/api/packages/naxos/generic/naxos-installer/latest/naxos-installer-x86_64-linux.iso" || true
|
|
|
|
# Attach asset to Gitea release v1.0.0 if present
|
|
RELEASE_ID=$(curl -s -H "Authorization: token ${TOKEN}" "${{ github.server_url }}/api/v1/repos/naxos/naxos-os/releases/tags/v1.0.0" | jq -r '.id // empty')
|
|
if [ -n "$RELEASE_ID" ]; then
|
|
echo "Attaching ISO to Gitea Release v1.0.0 (ID: $RELEASE_ID)..."
|
|
curl -s -X POST \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
-H "Content-Type: multipart/form-data" \
|
|
-F "attachment=@$ISO_FILE;filename=naxos-installer-x86_64-linux.iso" \
|
|
"${{ github.server_url }}/api/v1/repos/naxos/naxos-os/releases/$RELEASE_ID/assets?name=naxos-installer-x86_64-linux.iso" || true
|
|
fi
|