grafana/grafana-kiosk

View on GitHub
.github/workflows/ci.yml

Summary

Maintainability
Test Coverage
name: Build

on:
  push:
    branches:
      - '*'
    tags:
      - 'v*'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version-file: go.mod
          check-latest: true

      - name: Install dependencies
        run: go get .

      - name: Install golangci-lint
        uses: golangci/golangci-lint-action@v6
        with:
          version: latest
          args: --exclude-use-default
          skip-cache: true

      - name: Run Gosec Security Scanner
        uses: securego/gosec@master
        with:
          args: ./...

      - name: Get BRANCH, NAME, TAG
        id: branch_name
        run: |
          echo "SOURCE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
          echo "SOURCE_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
          echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

      - name: Build with Mage
        uses: magefile/mage-action@v3
        with:
          version: latest
          args: -v build:ci

      - name: Get PR
        uses: jwalton/gh-find-current-pr@master
        id: findPr
        with:
          state: open

      - name: Archive Build
        uses: actions/upload-artifact@v4
        if: success() && steps.findPr.outputs.number
        env:
          PR: ${{ steps.findPr.outputs.pr }}
        with:
          name: grafana-kiosk-pr-${{env.PR}}
          path: bin
          overwrite: true
          retention-days: 7

      - name: Upload Code Climate Report
        uses: paambaati/codeclimate-action@v9
        env:
          CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
        with:
          prefix: github.com/grafana/grafana-kiosk
          coverageLocations: |
            ${{github.workspace}}/coverage.out:gocov

      - name: Package Release
        id: package-release
        if: startsWith(github.ref, 'refs/tags/v')
        env:
          SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }}
        run: |
          export RELEASE_TARGET_DIR=grafana-kiosk-$SOURCE_TAG
          mkdir $RELEASE_TARGET_DIR
          cp -p bin/darwin_amd64/grafana-kiosk $RELEASE_TARGET_DIR/grafana-kiosk.darwin.amd64
          cp -p bin/darwin_arm64/grafana-kiosk $RELEASE_TARGET_DIR/grafana-kiosk.darwin.arm64
          cp -p bin/linux_386/grafana-kiosk $RELEASE_TARGET_DIR/grafana-kiosk.linux.386
          cp -p bin/linux_amd64/grafana-kiosk $RELEASE_TARGET_DIR/grafana-kiosk.linux.amd64
          cp -p bin/linux_arm64/grafana-kiosk $RELEASE_TARGET_DIR/grafana-kiosk.linux.arm64
          cp -p bin/linux_armv5/grafana-kiosk $RELEASE_TARGET_DIR/grafana-kiosk.linux.armv5
          cp -p bin/linux_armv6/grafana-kiosk $RELEASE_TARGET_DIR/grafana-kiosk.linux.armv6
          cp -p bin/linux_armv7/grafana-kiosk $RELEASE_TARGET_DIR/grafana-kiosk.linux.armv7
          cp -p bin/windows_amd64/grafana-kiosk $RELEASE_TARGET_DIR/grafana-kiosk.windows.amd64.exe
          zip -r grafana-kiosk-$SOURCE_TAG.zip $RELEASE_TARGET_DIR
          tar cf grafana-kiosk-$SOURCE_TAG.tar $RELEASE_TARGET_DIR
          gzip grafana-kiosk-$SOURCE_TAG.tar
          mv grafana-kiosk-$SOURCE_TAG.tar.gz $RELEASE_TARGET_DIR
          mv grafana-kiosk-$SOURCE_TAG.zip $RELEASE_TARGET_DIR

      - name: Upload Release Artifacts
        uses: actions/upload-artifact@v4
        if: startsWith(github.ref, 'refs/tags/v')
        with:
          name: upload-release-artifacts
          path: grafana-kiosk-v*/**

      - name: Release
        uses: softprops/action-gh-release@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        if: startsWith(github.ref, 'refs/tags/v')
        with:
          prerelease: true
          generate_release_notes: true
          files: |
            ./grafana-kiosk-v*/**
          body: |
            ** Draft release **