Update release.yml to use correct path hosts/services/cm-dashboard.nix instead of hosts/common/cm-dashboard.nix. Also update documentation in CLAUDE.md and README.md to reflect the correct file location.
128 lines
5.1 KiB
YAML
128 lines
5.1 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: 'Version to release (e.g., v0.1.0)'
|
|
required: true
|
|
default: 'v0.1.0'
|
|
|
|
jobs:
|
|
build-and-release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
profile: minimal
|
|
override: true
|
|
|
|
- name: Install system dependencies
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y pkg-config libssl-dev libzmq3-dev
|
|
|
|
- name: Build workspace (static)
|
|
run: |
|
|
export RUSTFLAGS="-C target-feature=+crt-static"
|
|
cargo build --release --workspace --target x86_64-unknown-linux-gnu
|
|
|
|
- name: Create release directory
|
|
run: |
|
|
mkdir -p release
|
|
cp target/x86_64-unknown-linux-gnu/release/cm-dashboard release/cm-dashboard-linux-x86_64
|
|
cp target/x86_64-unknown-linux-gnu/release/cm-dashboard-agent release/cm-dashboard-agent-linux-x86_64
|
|
|
|
- name: Create tarball
|
|
run: |
|
|
cd release
|
|
tar -czf cm-dashboard-linux-x86_64.tar.gz cm-dashboard-linux-x86_64 cm-dashboard-agent-linux-x86_64
|
|
|
|
- name: Set version variable
|
|
id: version
|
|
run: |
|
|
if [ "${{ gitea.event_name }}" == "workflow_dispatch" ]; then
|
|
echo "VERSION=${{ gitea.event.inputs.version }}" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Create Release with curl
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEATOKEN }}
|
|
run: |
|
|
VERSION="${{ steps.version.outputs.VERSION }}"
|
|
|
|
# Create release
|
|
curl -X POST \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"tag_name": "'$VERSION'",
|
|
"name": "cm-dashboard '$VERSION'",
|
|
"body": "## cm-dashboard '$VERSION'\n\nPre-built binaries for Linux x86_64:\n- cm-dashboard-linux-x86_64 - Dashboard TUI binary\n- cm-dashboard-agent-linux-x86_64 - Agent daemon binary\n- cm-dashboard-linux-x86_64.tar.gz - Combined tarball"
|
|
}' \
|
|
"https://gitea.cmtec.se/api/v1/repos/cm/cm-dashboard/releases"
|
|
|
|
# Get release ID
|
|
RELEASE_ID=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
|
|
"https://gitea.cmtec.se/api/v1/repos/cm/cm-dashboard/releases/tags/$VERSION" | \
|
|
grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
|
|
|
# Upload binaries
|
|
curl -X POST \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-F "attachment=@release/cm-dashboard-linux-x86_64" \
|
|
"https://gitea.cmtec.se/api/v1/repos/cm/cm-dashboard/releases/$RELEASE_ID/assets?name=cm-dashboard-linux-x86_64"
|
|
|
|
curl -X POST \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-F "attachment=@release/cm-dashboard-agent-linux-x86_64" \
|
|
"https://gitea.cmtec.se/api/v1/repos/cm/cm-dashboard/releases/$RELEASE_ID/assets?name=cm-dashboard-agent-linux-x86_64"
|
|
|
|
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"
|
|
|
|
- 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"
|
|
# Convert sha256 hex to base64 for Nix hash format using Python
|
|
NEW_HASH=$(sha256sum cm-dashboard.tar.gz | cut -d' ' -f1)
|
|
NIX_HASH="sha256-$(python3 -c "import base64, binascii; print(base64.b64encode(binascii.unhexlify('$NEW_HASH')).decode())")"
|
|
|
|
# Update the NixOS configuration
|
|
sed -i "s|version = \"v[^\"]*\"|version = \"$VERSION\"|" hosts/services/cm-dashboard.nix
|
|
sed -i "s|sha256 = \"sha256-[^\"]*\"|sha256 = \"$NIX_HASH\"|" hosts/services/cm-dashboard.nix
|
|
|
|
# Commit and push changes
|
|
git config user.name "Gitea Actions"
|
|
git config user.email "actions@gitea.cmtec.se"
|
|
git add hosts/services/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 |