55 lines
1.6 KiB
YAML
55 lines
1.6 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: codeberg-small
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "stable"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y chafa libglib2.0-dev jq
|
|
|
|
- name: Build binary
|
|
run: make build
|
|
|
|
- name: Test binary
|
|
run: ./gogofetch -h
|
|
|
|
- name: Package release artifact
|
|
run: |
|
|
tar -czvf gogofetch-${{ github.ref_name }}-linux-amd64.tar.gz gogofetch Makefile logos/
|
|
|
|
- name: Create Release and Upload Asset via API
|
|
run: |
|
|
TAG="${{ github.ref_name }}"
|
|
REPO="${{ github.repository }}"
|
|
TOKEN="${{ secrets.GITHUB_TOKEN }}"
|
|
ASSET="gogofetch-${TAG}-linux-amd64.tar.gz"
|
|
|
|
RELEASE_ID=$(curl -X POST "${{ github.server_url }}/api/v1/repos/${REPO}/releases" \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"${TAG}\",\"target_commitish\":\"master\",\"name\":\"Release ${TAG}\",\"body\":\"Automated binary release for Arch Linux AUR\",\"draft\":false,\"prerelease\":false}" \
|
|
| jq '.id')
|
|
|
|
echo "Created release with ID: ${RELEASE_ID}"
|
|
|
|
curl -X POST "${{ github.server_url }}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets" \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
-H "Accept: application/json" \
|
|
-F "attachment=@./${ASSET}"
|
|
|