From 1ed4666dfdbb769e2ec1a65befc7956d47600101 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sat, 25 Oct 2025 17:21:52 +0200 Subject: [PATCH] Add automated NixOS configuration updates to release workflow - Clone nixosbox repository after creating release - Download and hash new tarball automatically - Update version and hash in cm-dashboard.nix - Commit and push changes with automated message - Eliminates manual NixOS config update step --- .gitea/workflows/release.yml | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 7da1dab..a96eaf6 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -91,4 +91,37 @@ jobs: curl -X POST \ -H "Authorization: token $GITEA_TOKEN" \ -F "attachment=@release/cm-dashboard-linux-x86_64.tar.gz" \ - "https://gitea.cmtec.se/api/v1/repos/cm/cm-dashboard/releases/$RELEASE_ID/assets?name=cm-dashboard-linux-x86_64.tar.gz" \ No newline at end of file + "https://gitea.cmtec.se/api/v1/repos/cm/cm-dashboard/releases/$RELEASE_ID/assets?name=cm-dashboard-linux-x86_64.tar.gz" + + - name: Update NixOS Configuration + env: + GITEA_TOKEN: ${{ secrets.GITEATOKEN }} + run: | + VERSION="${{ steps.version.outputs.VERSION }}" + + # Clone nixosbox repository + git clone https://$GITEA_TOKEN@gitea.cmtec.se/cm/nixosbox.git nixosbox-update + cd nixosbox-update + + # Get hash for the new release tarball + TARBALL_URL="https://gitea.cmtec.se/cm/cm-dashboard/releases/download/$VERSION/cm-dashboard-linux-x86_64.tar.gz" + + # Download tarball to get correct hash + curl -L -o cm-dashboard.tar.gz "$TARBALL_URL" + NEW_HASH=$(sha256sum cm-dashboard.tar.gz | cut -d' ' -f1) + NIX_HASH="sha256-$(echo -n $NEW_HASH | xxd -r -p | base64)" + + # Update the NixOS configuration + sed -i "s/version = \"v[^\"]*\"/version = \"$VERSION\"/" hosts/common/cm-dashboard.nix + sed -i "s/sha256 = \"sha256-[^\"]*\"/sha256 = \"$NIX_HASH\"/" hosts/common/cm-dashboard.nix + + # Commit and push changes + git config user.name "Gitea Actions" + git config user.email "actions@gitea.cmtec.se" + git add hosts/common/cm-dashboard.nix + git commit -m "Auto-update cm-dashboard to $VERSION + + - Update version to $VERSION with automated release + - Update tarball hash for new static binaries + - Automated update from cm-dashboard release workflow" + git push \ No newline at end of file