117 lines
3.2 KiB
YAML
117 lines
3.2 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '**'
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build-backend:
|
|
name: Build Go Backend
|
|
runs-on: host-runner
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
sed -i 's|https://dl-cdn.alpinelinux.org|http://dl-cdn.alpinelinux.org|g' /etc/apk/repositories
|
|
apk add --no-cache go gcc musl-dev libpcap-dev
|
|
|
|
- name: Download modules
|
|
run: go mod download
|
|
|
|
- name: Build
|
|
run: go build -o bin/ids ./cmd/ids
|
|
|
|
- name: Upload binary
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ids-backend
|
|
path: bin/ids
|
|
retention-days: 7
|
|
|
|
- name: Clean up
|
|
run: rm -rf bin/
|
|
|
|
build-frontend:
|
|
name: Build Nuxt Frontend
|
|
runs-on: host-runner
|
|
defaults:
|
|
run:
|
|
working-directory: frontend
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
sed -i 's|https://dl-cdn.alpinelinux.org|http://dl-cdn.alpinelinux.org|g' /etc/apk/repositories
|
|
apk add --no-cache nodejs npm
|
|
npm install
|
|
|
|
- name: Build
|
|
run: npm run generate
|
|
|
|
- name: Upload dist
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ids-frontend
|
|
path: frontend/.output/public
|
|
retention-days: 7
|
|
|
|
- name: Clean up
|
|
run: rm -rf .output/
|
|
|
|
release:
|
|
name: Create Release
|
|
runs-on: host-runner
|
|
needs: [build-backend, build-frontend]
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
steps:
|
|
- name: Install curl
|
|
run: |
|
|
sed -i 's|https://dl-cdn.alpinelinux.org|http://dl-cdn.alpinelinux.org|g' /etc/apk/repositories
|
|
apk add --no-cache curl
|
|
|
|
- name: Download backend artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: ids-backend
|
|
path: release/
|
|
|
|
- name: Download frontend artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: ids-frontend
|
|
path: release/frontend/
|
|
|
|
- name: Pack frontend
|
|
run: tar -czf release/ids-frontend.tar.gz -C release/frontend .
|
|
|
|
- name: Create release and upload assets
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
TAG="${{ github.ref_name }}"
|
|
REPO="${{ github.repository }}"
|
|
SERVER="${{ github.server_url }}"
|
|
|
|
RELEASE_ID=$(curl -sf -X POST \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"${TAG}\",\"name\":\"Release ${TAG}\"}" \
|
|
"${SERVER}/api/v1/repos/${REPO}/releases" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
|
|
|
curl -sf -X POST \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-F "attachment=@release/ids" \
|
|
"${SERVER}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets"
|
|
|
|
curl -sf -X POST \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-F "attachment=@release/ids-frontend.tar.gz" \
|
|
"${SERVER}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets"
|