soumya92/barista

View on GitHub
.github/workflows/release.yml

Summary

Maintainability
Test Coverage
# Copyright 2020 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Release

on:
  push:
    branches: [ main ]

jobs:

  build:
    name: Release
    runs-on: ubuntu-latest
    steps:

    - name: Set up Go
      uses: actions/setup-go@v4
      with:
        go-version: 1.19

    - name: Check out code
      uses: actions/checkout@v3

    - name: Get dependencies
      run: go get -v -t -d ./...

    - name: Install go cover
      run: go install golang.org/x/tools/cmd/cover@latest

    - name: Fix apt-get state
      run: sudo apt-get update

    - name: Install apt packages
      run: sudo apt-get install libasound2-dev jq

    - name: Set up CodeClimate env
      run: |
        echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
        echo "GIT_COMMIT_SHA=$GITHUB_SHA" >> $GITHUB_ENV

    - name: Prepare CodeClimate
      env:
        CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
      run: |
        curl -LSs 'https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64' >./cc-test-reporter;
        chmod +x ./cc-test-reporter
        ./cc-test-reporter before-build

    - name: Run tests
      env:
        CI: true
      run: ./test.sh

    - name: Upload coverage
      env:
        CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
      run: |
        ./cc-test-reporter after-build --prefix 'barista.run/'

    - name: Build binaries
      env:
        GITHUB_CLIENT_ID: ${{ secrets.GITHUB_CLIENT_ID }}
        GITHUB_CLIENT_SECRET: ${{ secrets.GITHUB_CLIENT_SECRET }}
        GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
        GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
        OWM_API_KEY: ${{ secrets.OWM_API_KEY }}
      run: |
        ./build.sh -tags prod -o sample-bar ./samples/sample-bar
        go build -o i3status ./samples/i3status

    - name: Delete old tag and release
      uses: dev-drprasad/delete-tag-and-release@v1.1
      with:
        delete_release: true
        tag_name: autorelease
      env:
        GITHUB_TOKEN: ${{ secrets.DROID_GITHUB_TOKEN }}


    - name: Create/Update Release
      uses: "marvinpinto/action-automatic-releases@latest"
      with:
        repo_token: "${{ secrets.DROID_GITHUB_TOKEN }}"
        automatic_release_tag: "autorelease"
        prerelease: false
        title: "Automated build"
        files: |
          i3status
          sample-bar