115 lines
4.0 KiB
YAML
115 lines
4.0 KiB
YAML
name: build
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v[0-9]+.[0-9]+'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Setup go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: '>=1.20'
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0 # all history for all branches and tags
|
|
|
|
- name: Install dependencies
|
|
run: go mod download
|
|
|
|
- name: Linux build topip amd64
|
|
run: GOOS=linux GOARCH=amd64 go build -o bin/topip-linux-amd64
|
|
|
|
- name: Linux build topip arm64
|
|
run: GOOS=linux GOARCH=arm64 go build -o bin/topip-linux-arm64
|
|
|
|
- name: Darwin build topip amd64
|
|
run: GOOS=darwin GOARCH=amd64 go build -o bin/topip-darwin-amd64
|
|
|
|
- name: Darwin build topip arm64
|
|
run: GOOS=darwin GOARCH=arm64 go build -o bin/topip-darwin-arm64
|
|
|
|
- name: Linux build topgeoip amd64
|
|
run: GOOS=linux GOARCH=amd64 go build -o ../bin/topgeoip-linux-amd64
|
|
working-directory: geo
|
|
|
|
- name: Linux build topgeoip arm64
|
|
run: GOOS=linux GOARCH=arm64 go build -o ../bin/topgeoip-linux-arm64
|
|
working-directory: geo
|
|
|
|
- name: Darwin build topgeoip amd64
|
|
run: GOOS=darwin GOARCH=amd64 go build -o ../bin/topgeoip-darwin-amd64
|
|
working-directory: geo
|
|
|
|
- name: Darwin build topgeoip arm64
|
|
run: GOOS=darwin GOARCH=arm64 go build -o ../bin/topgeoip-darwin-arm64
|
|
working-directory: geo
|
|
|
|
- name: Create deb dir tree
|
|
run: |
|
|
mkdir -p topip-amd64/usr/bin
|
|
mkdir -p topip-amd64/DEBIAN
|
|
mkdir -p topip-arm64/usr/bin
|
|
mkdir -p topip-arm64/DEBIAN
|
|
|
|
- name: Copy binaries
|
|
run: |
|
|
cp bin/topip-linux-amd64 topip-amd64/usr/bin/topip
|
|
cp bin/topip-linux-arm64 topip-arm64/usr/bin/topip
|
|
cp bin/topgeoip-linux-amd64 topip-amd64/usr/bin/topgeoip
|
|
cp bin/topgeoip-linux-arm64 topip-arm64/usr/bin/topgeoip
|
|
|
|
- name: Get version
|
|
run: |
|
|
TAG=${{ gitea.ref_name }}
|
|
echo "VERSION=${TAG#v}" | tee -a $GITEA_ENV
|
|
|
|
- name: Prepare amd64 control file
|
|
run: |
|
|
echo "Package: topip" > topip-amd64/DEBIAN/control
|
|
echo "Version: $VERSION" >> topip-amd64/DEBIAN/control
|
|
echo "Maintainer: tchivert <me@tchv.fr>" >> topip-amd64/DEBIAN/control
|
|
echo "Architecture: amd64" >> topip-amd64/DEBIAN/control
|
|
echo "Homepage: https://git.rznet.fr/tchivert/topip" >> topip-amd64/DEBIAN/control
|
|
echo "Description: simple terminal log reader for haproxy" >> topip-amd64/DEBIAN/control
|
|
|
|
- name: Prepare arm64 control file
|
|
run: |
|
|
echo "Package: topip" > topip-arm64/DEBIAN/control
|
|
echo "Version: $VERSION" >> topip-arm64/DEBIAN/control
|
|
echo "Maintainer: tchivert <me@tchv.fr>" >> topip-arm64/DEBIAN/control
|
|
echo "Architecture: arm64" >> topip-arm64/DEBIAN/control
|
|
echo "Homepage: https://git.rznet.fr/tchivert/topip" >> topip-arm64/DEBIAN/control
|
|
echo "Description: simple terminal log reader for haproxy" >> topip-arm64/DEBIAN/control
|
|
|
|
- name: Build deb files
|
|
run: |
|
|
dpkg -b topip-amd64 bin/topip-amd64.deb
|
|
dpkg -b topip-arm64 bin/topip-arm64.deb
|
|
|
|
- name: Create release
|
|
uses: https://gitea.com/actions/release-action@main
|
|
with:
|
|
draft: false
|
|
prerelease: false
|
|
files: |-
|
|
bin/**
|
|
api_key: "${{ secrets.RELEASE_TOKEN }}"
|
|
|
|
- name: Prepare apt repo upload
|
|
run: |
|
|
mv bin/topip-amd64.deb topip_$VERSION-1_amd64.deb
|
|
mv bin/topip-arm64.deb topip_$VERSION-1_arm64.deb
|
|
|
|
- name: Release packages
|
|
run: |
|
|
curl -s -u "${{ secrets.PACKAGE_TOKEN }}" --upload-file topip_$VERSION-1_amd64.deb \
|
|
https://git.rznet.fr/api/packages/tchivert/debian/pool/stable/main/upload
|
|
curl -s -u "${{ secrets.PACKAGE_TOKEN }}" --upload-file topip_$VERSION-1_arm64.deb \
|
|
https://git.rznet.fr/api/packages/tchivert/debian/pool/stable/main/upload
|