All checks were successful
Build and Test / build-and-test (push) Successful in 35s
Replace the workflow_dispatch deploy with an Activate step in build.yml that runs only for X.Y.Z tags: it repoints the ~/hsa-app/hsa symlink and restarts the user service. Pre-release tags (e.g. 0.0.0a2) are still built, tested, and staged into releases/ but not activated. Remove deploy.yml and update INSTALL.md accordingly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
44 lines
1.9 KiB
YAML
44 lines
1.9 KiB
YAML
name: Build and Test
|
|
on: [push]
|
|
jobs:
|
|
build-and-test:
|
|
runs-on: shell
|
|
steps:
|
|
- name: Checkout
|
|
run: |
|
|
git clone --branch ${{ github.ref_name }} ${{ github.server_url }}/${{ github.repository }}.git .
|
|
- name: Test
|
|
run: docker run --rm -w /src -v $PWD:/src golang:1.26 go test ./...
|
|
- name: Build
|
|
run: docker run --rm -w /src -v $PWD:/src -e CGO_ENABLED=0 golang:1.26 go build -buildvcs=false -ldflags "-s -w" -o hsa ./cmd/hsa
|
|
- name: Upload binary
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: hsa
|
|
path: hsa
|
|
- name: Stage release
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
run: |
|
|
echo "${{ secrets.FORGEJO_SSH }}" > /tmp/deploy_key
|
|
chmod 600 /tmp/deploy_key
|
|
TAG=${{ github.ref_name }}
|
|
REL=hsa-app/releases/hsa-app-V$TAG
|
|
TARGET=${{ vars.HSA_APP_USER }}@${{ vars.HSA_APP_HOST }}
|
|
ssh -i /tmp/deploy_key -o StrictHostKeyChecking=no $TARGET "mkdir -p $REL"
|
|
scp -i /tmp/deploy_key -o StrictHostKeyChecking=no hsa $TARGET:$REL/hsa
|
|
ssh -i /tmp/deploy_key -o StrictHostKeyChecking=no $TARGET "chmod +x $REL/hsa"
|
|
rm /tmp/deploy_key
|
|
- name: Activate release
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
run: |
|
|
TAG=${{ github.ref_name }}
|
|
if ! echo "$TAG" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
|
|
echo "Tag $TAG is a pre-release; staged but not activated."
|
|
exit 0
|
|
fi
|
|
echo "${{ secrets.FORGEJO_SSH }}" > /tmp/deploy_key
|
|
chmod 600 /tmp/deploy_key
|
|
TARGET=${{ vars.HSA_APP_USER }}@${{ vars.HSA_APP_HOST }}
|
|
ssh -i /tmp/deploy_key -o StrictHostKeyChecking=no $TARGET \
|
|
"cd hsa-app && ln -sfn releases/hsa-app-V$TAG/hsa hsa && systemctl --user restart hsa_app"
|
|
rm /tmp/deploy_key
|