Skip to content

Workflow file for this run

name: Build and Package Release
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write # Required to upload assets to releases
actions: read # Needed to access action outputs
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: Build Go binary
run: |
VERSION=$(git describe --tags)
cd backend
CGO_ENABLED=0 go build -ldflags "-X 'github.com/${{ github.repository }}/version.Version=${VERSION}'" -o main .
- name: Install UPX
run: |
sudo apt-get update
sudo apt-get install -y upx
ls ${{ github.workspace }}
upx --best --lzma ${{ github.workspace }}/backend/main
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Build Vue frontend
run: |
cd frontend
npm install
npm run build-only
- name: Create a zip file with the frontend artifacts
run: |
zip -r vue3-app.zip frontend/dist
- name: Get Release ID
id: get_release_id
run: |
release_id=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.ref_name }} | jq -r .id)
echo "RELEASE_ID=$release_id" >> $GITHUB_ENV
- name: Upload binary to release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: backend/main
asset_name: main
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload frontend to release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: vue3-app.zip
asset_name: frontend.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}