Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build Release Artifact
on:
workflow_dispatch:
jobs:
compile:
timeout-minutes: 10
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3
- uses: actions/setup-go@v6
with:
cache: true
go-version-file: go.mod
- name: Show System
run: |
uname -a
just sysinfo
- name: Build Artifact
run: |
just compile
- uses: actions/upload-artifact@v7
with:
name: "ubs"
path: ".bin/nerfs"
retention-days: 4
compression-level: 9
if-no-files-found: error
overwrite: true
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
run-tests:
timeout-minutes: 5
runs-on: fedora-41
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: extractions/setup-just@v2
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

set -euo pipefail

binary="${1}"

archives=$(curl -s -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/cattlecloud/${binary}/actions/artifacts")

best=$(echo "${archives}" | jq -r '.artifacts | sort_by(.created_at) | last | .archive_download_url')
dest="/tmp/${binary}.zip"
file="/tmp/${binary}"

echo "downloading ${best} into ${dest}"
curl -L -H "Authorization: Bearer ${GITHUB_TOKEN}" -H "X-GitHub-Api-Version: 2022-11-28" -o "${dest}" -s "${best}"
pushd /tmp && unzip "${dest}" && popd
echo "download complete."

scp "${file}" "${HOST}:~/${binary}"
ssh -t "${HOST}" "sudo mv ~/${binary} /opt/bin/${binary}"
ssh -t "${HOST}" "sudo systemctl restart ${binary}"
ssh -t "${HOST}" "sudo systemctl status ${binary}"

rm "${dest}" "${file}"
echo "done."

10 changes: 10 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,13 @@ lint: vet
[group('build')]
init:
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.4

# deploy artifact
[group('deploy')]
deploy host:
HOST={{host}} envy exec gh-cattle $scripts/deploy.sh nerfs

# create release artifact
[group('deploy')]
artifact:
gh workflow run build.yaml
Loading