Skip to content

Commit

Permalink
build: move to common workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
clambin committed Mar 15, 2022
1 parent c6adc5a commit c823818
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 224 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/analysis.yml

This file was deleted.

93 changes: 6 additions & 87 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,94 +4,13 @@ on:
push:
branches:
- master
- refactor
- fix

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v2
with:
go-version: 1.17
- name: test
run: |
go test ./... -race -coverprofile=coverage.txt -covermode=atomic
- uses: codecov/[email protected]
with:
file: coverage.txt
token: ${{ secrets.CODECOV_TOKEN }}
uses: clambin/workflows/.github/workflows/test.yaml@main
build:
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
target: [ pinger ]
platform: [ linux ]
arch: [ amd64, arm, arm64 ]
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Version number
id: vars
run: echo ::set-output name=tag::${GITHUB_REF##*/}
- name: build
env:
TARGET: ${{ matrix.target }}
GOOS: ${{ matrix.platform }}
GOARCH: ${{ matrix.arch }}
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
run: |
go build \
-ldflags "-X github.com/clambin/pinger/version.BuildVersion=$RELEASE_VERSION" \
-o bld/$TARGET-$GOOS-$GOARCH \
$TARGET.go
- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.target }}-${{ matrix.platform }}-${{ matrix.arch }}
path: ./bld/*
docker:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/download-artifact@v2
with:
name: pinger-linux-arm
path: ./bld
- uses: actions/download-artifact@v2
with:
name: pinger-linux-arm64
path: ./bld
- uses: actions/download-artifact@v2
with:
name: pinger-linux-amd64
path: ./bld
- name: Fix permissions
run: chmod +x bld/*
- uses: docker/setup-qemu-action@v1
- uses: docker/[email protected]
- uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/[email protected]
id: pinger_meta
with:
images: ghcr.io/clambin/pinger
tags: |
type=sha
type=semver,pattern={{version}}
- name: docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./build/Dockerfile
platforms: linux/amd64,linux/arm,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.pinger_meta.outputs.tags }}
labels: ${{ steps.pinger_meta.outputs.labels }}
needs:
- test
uses: clambin/workflows/.github/workflows/build.yaml@main
with:
target: pinger
115 changes: 11 additions & 104 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,112 +3,19 @@ name: Release
on:
push:
tags:
- '*'
- 'v*'

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v2
with:
go-version: 1.17
- name: test
run: |
go test ./... -race -coverprofile=coverage.txt -covermode=atomic
- uses: codecov/[email protected]
with:
file: coverage.txt
token: ${{ secrets.CODECOV_TOKEN }}
uses: clambin/workflows/.github/workflows/test.yaml@main
build:
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
target: [ pinger ]
platform: [ linux ]
arch: [ amd64, arm, arm64 ]
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Version number
id: vars
run: echo ::set-output name=tag::${GITHUB_REF##*/}
- name: build
env:
TARGET: ${{ matrix.target }}
GOOS: ${{ matrix.platform }}
GOARCH: ${{ matrix.arch }}
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
run: |
go build \
-ldflags "-X github.com/clambin/pinger/version.BuildVersion=$RELEASE_VERSION" \
-o bld/$TARGET-$GOOS-$GOARCH \
$TARGET.go
- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.target }}-${{ matrix.platform }}-${{ matrix.arch }}
path: ./bld/*
docker:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/download-artifact@v2
with:
name: pinger-linux-arm
path: ./bld
- uses: actions/download-artifact@v2
with:
name: pinger-linux-arm64
path: ./bld
- uses: actions/download-artifact@v2
with:
name: pinger-linux-amd64
path: ./bld
- name: Fix permissions
run: chmod +x bld/*
- uses: docker/setup-qemu-action@v1
- uses: docker/[email protected]
- uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/[email protected]
id: pinger_meta
with:
images: ghcr.io/clambin/pinger
tags: |
type=sha
type=semver,pattern={{version}}
- name: docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./build/Dockerfile
platforms: linux/amd64,linux/arm,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.pinger_meta.outputs.tags }}
labels: ${{ steps.pinger_meta.outputs.labels }}
publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/download-artifact@v2
with:
path: ./artifacts
- name: Move binaries into place
run: |
mkdir bld
mv artifacts/*/* bld
- uses: marvinpinto/[email protected]
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
bld/*
needs:
- test
uses: clambin/workflows/.github/workflows/build.yaml@main
with:
target: pinger
release:
needs:
- build
uses: clambin/workflows/.github/workflows/release.yaml@main

16 changes: 1 addition & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,8 @@ on:
push:
branches-ignore:
- master
- refactor
- fix
pull_request_target:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v2
with:
go-version: 1.17
- name: test
run: |
go test ./... -race -coverprofile=coverage.txt -covermode=atomic
- uses: codecov/[email protected]
with:
file: coverage.txt
token: ${{ secrets.CODECOV_TOKEN }}
uses: clambin/workflows/.github/workflows/test.yaml@main
9 changes: 9 additions & 0 deletions .github/workflows/vulnerabilities.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Vulnerabilities

on:
schedule:
- cron: '23 3 * * 6'

jobs:
vulnerabilities:
uses: clambin/workflows/.github/workflows/vulnerabilities.yaml@main

0 comments on commit c823818

Please sign in to comment.