Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: put built binaries into artifact #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions .github/workflows/build-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Build artifacts
on:
push:
tags:
- v*
pull_request: {}

jobs:
preflight:
timeout-minutes: 5
runs-on: ubuntu-22.04
outputs:
doit: ${{ steps.git-diff.outputs.diff != '' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) }}
really: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
steps:
- uses: actions/checkout@v3
if: ${{ github.event_name != 'push' && !startsWith(github.ref, 'refs/tags/v') }}

- uses: technote-space/get-diff-action@v5
if: ${{ github.event_name != 'push' && !startsWith(github.ref, 'refs/tags/v') }}
id: git-diff
with:
PATTERNS: |
.github/workflows/build-artifacts.yml

- run: |
echo "${{ steps.git-diff.outputs.diff }}"
echo "${{ steps.git-diff.outputs.diff == '' }}"
echo "${{ github.event_name == 'push' }}"
echo "${{ startsWith(github.ref, 'refs/tags/v') }}"
echo "${{ github.ref }}"
echo "${{ github.event_name }}"
echo "${{ steps.git-diff.outputs.diff != '' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) }}"


agent:
timeout-minutes: 20
needs:
- preflight
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ./
steps:

###########
########### PREREQUISITES
###########

- uses: actions/checkout@v3
if: ${{ needs.preflight.outputs.doit == 'true' }}
with:
fetch-depth: 0
lfs: true

- name: Install Go
uses: actions/setup-go@v3
if: ${{ needs.preflight.outputs.doit == 'true' }}
with:
go-version: '1.20'

- id: go-cache-paths
if: ${{ needs.preflight.outputs.doit == 'true' }}
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"

# shared with unit-tests-agent
- uses: actions/cache@v3
if: ${{ needs.preflight.outputs.doit == 'true' }}
with:
path: |
${{ steps.go-cache-paths.outputs.go-build }}
${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-agent-${{ hashFiles('agent/go.sum') }}
restore-keys: |
${{ runner.os }}-agent-

###########
########### BUILD
###########

- name: Setup action variables
if: ${{ needs.preflight.outputs.doit == 'true' }}
id: locals
run: |
echo "::set-output name=release_id::$(git describe --tags)"

- name: Build for Linux
if: ${{ needs.preflight.outputs.doit == 'true' }}
env:
LDFLAGS_EXTRA: -s
run: |
make Linux

- name: Build Debian and RPM installer packages
if: ${{ needs.preflight.outputs.doit == 'true' }}
env:
RELEASE_ID: ${{ steps.locals.outputs.release_id }}
run: |
cp ./guard-linux ./_packaging/nfpm/
cd ./_packaging/nfpm
make

- name: Setup artifact dir
if: ${{ needs.preflight.outputs.doit == 'true' }}
run: |
mkdir ./agent-binaries
cp ./guard-linux ./agent-binaries/guard-linux-${{ steps.locals.outputs.release_id }}
cp ./_packaging/nfpm/guard-1*.rpm ./agent-binaries
cp ./_packaging/nfpm/guard_1*.deb ./agent-binaries

- name: Upload artifacts
if: ${{ needs.preflight.outputs.doit == 'true' }}
uses: actions/upload-artifact@v3
with:
name: release
path: ./agent-binaries