Skip to content

Deployer types

Deployer types #447

Workflow file for this run

name: Build
on:
push:
branches:
- main
tags:
- v*
pull_request:
jobs:
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Hard-coding version due to this bug: https://github.com/golangci/golangci-lint-action/issues/535
version: v1.52.2
test:
name: go test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: go-test-${{ hashFiles('**/go.sum') }}
restore-keys: go-test-
- name: Run go test
run: |
set -euo pipefail
go generate
go test -coverprofile /tmp/coverage.out -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
echo "# Code coverage summary" > /tmp/coverage.md
echo "|File|Type|Coverage|" >> /tmp/coverage.md
echo "|----|----|--------|" >> /tmp/coverage.md
go tool cover -func /tmp/coverage.out | sed -e 's/\s\s*/|/g' -e 's/^/|/g' -e 's/$/|/g' >> /tmp/coverage.md
cat /tmp/coverage.md >> $GITHUB_STEP_SUMMARY
echo "::group::Code coverage summary"
go tool cover -func /tmp/coverage.out
echo "::endgroup::"
- name: Upload test log
uses: actions/upload-artifact@v3
if: always()
with:
name: test-results
path: |
/tmp/gotest.log
/tmp/coverage.out
/tmp/coverage.md
if-no-files-found: error
generate:
name: go generate
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: go-test-${{ hashFiles('**/go.sum') }}
restore-keys: go-generate-
- name: Run go generate
run: ./.github/scripts/gogenerate.sh
release:
name: release
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- golangci-lint
- test
- generate
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Login to Quay.io
uses: docker/login-action@v2
if: startsWith(github.event.ref, 'refs/tags/')
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and release
uses: goreleaser/goreleaser-action@v4
if: startsWith(github.event.ref, 'refs/tags/')
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOPROXY: direct
GOSUMDB: off
- name: Build
uses: goreleaser/goreleaser-action@v4
if: ${{ !startsWith(github.event.ref, 'refs/tags/') }}
with:
distribution: goreleaser
version: latest
args: build --snapshot
env:
GOPROXY: direct
GOSUMDB: off
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: binaries
path: dist
build_python_wheel:
name: build python wheel
runs-on: ubuntu-latest
needs:
- release
steps:
- name: version format check
if: startsWith(github.event.ref, 'refs/tags/')
shell: bash
env:
VERSION: ${{ github.ref_name }}
run: |
[[ ${VERSION//[[:blank:]]/} =~ ^v[[:digit:]]+\.[[:digit:]]\.[[:digit:]](-[[:alnum:]]+)?(\+[[:alnum:]]+)?$ ]] && export OK="[INF] version format accepted"
[[ -z $OK ]] && echo "[ERR] wrong version format: $VERSION" && exit 1
echo $OK
- name: Check out code
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: binaries
path: python/artifacts
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
architecture: 'x64'
- name: Grab the License file
run: |
cp LICENSE python/
- name: Fetch python dependencies
working-directory: python
shell: bash
run: |
make setup
- name: Bump version
working-directory: python
if: startsWith(github.event.ref, 'refs/tags/')
env:
VERSION: ${{ github.ref_name }}
shell: bash
run: |
sed -ri "s/^(.+version=')(.+)('.*)/\1${VERSION/v/}\3/g" setup.py
- name: Build python wheel
working-directory: python
run: |
make all
- name: Push to pypi
working-directory: python
if: startsWith(github.event.ref, 'refs/tags/')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{secrets.PYPI_TOKEN}}
run: |
twine upload dist/*