Some checks failed
Build and Release / build-and-release (push) Failing after 1m18s
Gitea Actions runner doesn't have sudo available
93 lines
3.3 KiB
YAML
93 lines
3.3 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
|
|
run: |
|
|
cargo build --release --workspace
|
|
|
|
- name: Create release directory
|
|
run: |
|
|
mkdir -p release
|
|
cp target/release/cm-dashboard release/cm-dashboard-linux-x86_64
|
|
cp target/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 }}" >> $GITEA_OUTPUT
|
|
else
|
|
echo "VERSION=${GITEA_REF#refs/tags/}" >> $GITEA_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" |