Skip to content

add release action + some more UT coverage #36

add release action + some more UT coverage

add release action + some more UT coverage #36

Workflow file for this run

name: ci
on:
pull_request:
branches:
- main
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.run_number || github.event.pull_request.number }}
cancel-in-progress: true
jobs:
test:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set VERSION env
run: echo "VERSION=$(cat splitio/version.go | grep 'Version =' | awk '{print $3}' | tr -d '"')" >> $GITHUB_ENV
- name: Version validation
if: ${{ github.event_name == 'pull_request' }}
uses: mukunku/tag-exists-action@v1.2.0
id: checkTag
with:
tag: ${{ env.VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Fail workflow if tag exists
if: ${{ github.event_name == 'pull_request' && steps.checkTag.outputs.exists == 'true' }}
uses: actions/github-script@v6.4.0
with:
script: core.setFailed('[ERROR] Tag already exists.')
- name: Setup Go version
uses: actions/setup-go@v4
with:
go-version: '^1.19.1'
- name: Build binaries for host machine
run: make splitd splitcli
- name: Run tests
run: make test
- name: Cross build for GNU Linux & Darwin x amd64 & arm64
run: make binaries_release
- name: SonarQube Scan
uses: SonarSource/sonarcloud-github-action@v1.9.1
env:
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
projectBaseDir: .
args: >
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }}
-Dsonar.projectVersion=${{ env.VERSION }}
- name: Git tag
if: ${{ github.event_name == 'push' }}
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ env.VERSION }}
tag_prefix: 'v'
- name: Release
uses: softprops/action-gh-release@v1
if: ${{ github.event_name == 'push' }}
with:
name: splitd-${{ env.VERSION }}
files: |
splitd-darwin-amd64-${{ env.VERSION }}.bin
splitd-darwin-arm-${{ env.VERSION }}.bin
splitd-linux-amd64-${{ env.VERSION }}.bin
splitd-linux-arm-${{ env.VERSION }}.bin