72 lines
2.1 KiB
YAML
72 lines
2.1 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- "v*"
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
inputs:
|
|
release_tag:
|
|
description: "Optional tag to release (e.g. v1.1)"
|
|
required: false
|
|
type: string
|
|
|
|
jobs:
|
|
build:
|
|
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
|
|
runs-on: ubuntu-latest
|
|
container: debian:11
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install build dependencies
|
|
run: apt-get update && apt-get install -y --no-install-recommends make g++ git tar ca-certificates
|
|
|
|
- name: Build
|
|
run: make clean build
|
|
|
|
release:
|
|
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) || (github.event_name == 'workflow_dispatch' && inputs.release_tag != '')
|
|
runs-on: ubuntu-latest
|
|
container: debian:11
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- name: Checkout (tag push)
|
|
uses: actions/checkout@v4
|
|
if: github.event_name == 'push'
|
|
|
|
- name: Checkout (manual tag)
|
|
uses: actions/checkout@v4
|
|
if: github.event_name == 'workflow_dispatch'
|
|
with:
|
|
ref: ${{ inputs.release_tag }}
|
|
|
|
- name: Install build dependencies
|
|
run: apt-get update && apt-get install -y --no-install-recommends make g++ git tar ca-certificates
|
|
|
|
- name: Build release tarball
|
|
run: make release VERSION=${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name }}
|
|
|
|
- name: Upload workflow artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: fetchit-${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name }}-linux-x86_64-gnu
|
|
path: dist/*.tar.gz
|
|
|
|
- name: Publish GitHub release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name }}
|
|
files: dist/*.tar.gz
|
|
overwrite_files: true
|
|
generate_release_notes: true
|