Merge pull request #62 from slok/slok/update-deps #215
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: [push, pull_request] | |
jobs: | |
check: | |
name: Check | |
runs-on: ubuntu-latest | |
# Execute the checks inside the container instead the VM. | |
container: golangci/golangci-lint:v1.58.0-alpine | |
steps: | |
- uses: actions/checkout@v3 | |
- run: | | |
# We need this go flag because it started to error after golangci-lint is using Go 1.21. | |
# TODO(slok): Remove it on next (>1.54.1) golangci-lint upgrade to check if this problem has gone. | |
export GOFLAGS="-buildvcs=false" | |
./scripts/check/check.sh | |
unit-test: | |
name: Unit test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v3 | |
with: | |
go-version-file: go.mod | |
- run: make ci-test | |
- uses: codecov/codecov-action@v3.1.1 | |
with: | |
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }} | |
file: ./.test_coverage.txt | |
fail_ci_if_error: false | |
rolling-release-images: | |
# Only on main branch. | |
if: startsWith(github.ref, 'refs/heads/main') | |
env: | |
TAG_IMAGE_LATEST: "true" | |
PROD_IMAGE_NAME: ghcr.io/${GITHUB_REPOSITORY} | |
VERSION: ${GITHUB_SHA} | |
needs: [check, unit-test] | |
name: Release images | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Docker login | |
run: docker login ghcr.io -u ${{ github.actor }} -p "${{ secrets.GITHUB_TOKEN }}" | |
- name: Build and publish docker images | |
run: make build-publish-image-all | |
tagged-release-images: | |
# Only on tags. | |
if: startsWith(github.ref, 'refs/tags/') | |
env: | |
PROD_IMAGE_NAME: ghcr.io/${GITHUB_REPOSITORY} | |
needs: [check, unit-test] | |
name: Tagged release images | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo "VERSION=${GITHUB_REF#refs/*/}" >> ${GITHUB_ENV} # Sets VERSION env var. | |
- uses: actions/checkout@v3 | |
- name: Docker login | |
run: docker login ghcr.io -u ${{ github.actor }} -p "${{ secrets.GITHUB_TOKEN }}" | |
- name: Build and publish docker images | |
run: make build-publish-image-all | |
tagged-release-binaries: | |
# Only on tags. | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: [check, unit-test] | |
name: Tagged release binaries | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo "VERSION=${GITHUB_REF#refs/*/}" >> ${GITHUB_ENV} # Sets VERSION env var. | |
- uses: actions/checkout@v3 | |
- name: Build binaries | |
run: | | |
mkdir -p ./bin | |
chmod -R 0777 ./bin | |
make build-all | |
- name: Upload binaries | |
uses: xresloader/upload-to-github-release@v1.3.9 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
file: "bin/*" | |
tags: true | |
draft: true |