mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-16 04:24:56 +02:00
Merge pull request #18 from eosswedenorg/14-github-actions-build-and-package-on-release
GitHub actions build and package on release
This commit is contained in:
commit
85352b00ae
2 changed files with 107 additions and 1 deletions
106
.github/workflows/release.yml
vendored
Normal file
106
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
name: Package
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [ created ]
|
||||
|
||||
jobs:
|
||||
cross-compile:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ linux, freebsd ]
|
||||
arch: [ 386, amd64, arm, arm64 ]
|
||||
name: Crosscompile - ${{matrix.os}}-${{matrix.arch}}
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.18
|
||||
|
||||
- name: compile
|
||||
id: compile
|
||||
run: |
|
||||
GOOS=${{matrix.os}} GOARCH=${{matrix.arch}} make
|
||||
FILE=$(find build -type f | head -1)
|
||||
echo "version=$(sed -n 's/.*PROGRAM_VERSION\s*=\s*//p' Makefile)" >> "$GITHUB_OUTPUT"
|
||||
echo "filename=$FILE" >> "$GITHUB_OUTPUT"
|
||||
echo "name=$(basename $FILE)" >> "$GITHUB_OUTPUT"
|
||||
echo "mime=$(file -bi $FILE)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Upload
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_name: ${{ steps.compile.outputs.name }}-${{steps.compile.outputs.version}}-${{matrix.os}}-${{matrix.arch}}
|
||||
asset_path: ${{ steps.compile.outputs.filename }}
|
||||
asset_content_type: ${{ steps.compile.outputs.mime }}
|
||||
|
||||
package-ubuntu:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-22.04 ]
|
||||
name: Package - ${{matrix.os}}
|
||||
runs-on: ${{matrix.os}}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.18
|
||||
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install build-essential fakeroot debhelper quilt
|
||||
|
||||
- name: Package
|
||||
id: package
|
||||
run: |
|
||||
dpkg-buildpackage -b -us -uc
|
||||
DEB_FILE=$(ls ../*.deb | head -1)
|
||||
echo "deb_filename=$DEB_FILE" >> "$GITHUB_OUTPUT"
|
||||
echo "deb_name=$(basename $DEB_FILE)" >> "$GITHUB_OUTPUT"
|
||||
CH_FILE=$(ls ../*.changes | head -1)
|
||||
echo "ch_filename=$CH_FILE" >> "$GITHUB_OUTPUT"
|
||||
echo "ch_name=$(basename $CH_FILE)" >> "$GITHUB_OUTPUT"
|
||||
INFO_FILE=$(ls ../*.buildinfo | head -1)
|
||||
echo "info_filename=$INFO_FILE" >> "$GITHUB_OUTPUT"
|
||||
echo "info_name=$(basename $INFO_FILE)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Upload (package)
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_name: ${{ steps.package.outputs.deb_name }}
|
||||
asset_path: ${{ steps.package.outputs.deb_filename }}
|
||||
asset_content_type: application/x-deb
|
||||
|
||||
- name: Upload (.changes)
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_name: ${{ steps.package.outputs.ch_name }}
|
||||
asset_path: ${{ steps.package.outputs.ch_filename }}
|
||||
asset_content_type: text/plain
|
||||
|
||||
- name: Upload (buildinfo)
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_name: ${{ steps.package.outputs.info_name }}
|
||||
asset_path: ${{ steps.package.outputs.info_filename }}
|
||||
asset_content_type: text/plain
|
||||
2
Makefile
2
Makefile
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
GO=go
|
||||
GOBUILDFLAGS=-v --buildmode=pie -ldflags="-v -s -w -X main.VersionString=$(PROGRAM_VERSION)"
|
||||
GOBUILDFLAGS=-v -ldflags="-v -s -w -X main.VersionString=$(PROGRAM_VERSION)"
|
||||
PROGRAM=thalos-server
|
||||
PROGRAM_VERSION=0.1.0
|
||||
PREFIX=/usr/local
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue