diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a7fb030..43e7be9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -8,8 +8,50 @@ on: permissions: contents: write jobs: - goreleaser: + Test: + name: Unit tests with coverage runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go 1.17 + uses: actions/setup-go@v2 + with: + go-version: 1.17 + - name: Running go tests with coverage + env: + GO111MODULE: on + run: make cover + - name: Send coverage + uses: shogo82148/actions-goveralls@v1 + with: + path-to-profile: coverage.out + Lint: + name: Lint checks + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go 1.17 + uses: actions/setup-go@v2 + with: + go-version: 1.17 + - name: Download golangci-lint + run: | + wget https://github.com/golangci/golangci-lint/releases/download/v1.41.0/golangci-lint-1.41.0-linux-amd64.tar.gz + tar -xvf ./golangci-lint-1.41.0-linux-amd64.tar.gz + - name: Running golangci-lint + env: + GO111MODULE: on + GOPATH: /home/runner/work/ + run: GOLINTER=./golangci-lint-1.41.0-linux-amd64/golangci-lint make lint + Publish: + runs-on: ubuntu-latest + needs: [Test, Lint] steps: - name: Checkout uses: actions/checkout@v2 @@ -21,19 +63,16 @@ jobs: go-version: 1.17 - name: Login to Docker Hub if: startsWith(github.ref, 'refs/tags/v') - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - # TODO: default GITHUB_TOKEN insufficient permissions + # Publish image to Docker Hub, changelog and package to Github Release by GoReleaser - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: - # either 'goreleaser' (default) or 'goreleaser-pro' distribution: goreleaser version: latest args: release --rm-dist env: - GITHUB_TOKEN: ${{ secrets.GH_PAT }} - # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution - # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GH_PAT }} \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 047f5bf..5a4e39f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,39 +10,38 @@ on: - main jobs: - test: + Test: name: Unit tests with coverage - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] + runs-on: ubuntu-latest steps: - - name: Set up Go 1.17 - uses: actions/setup-go@v2 - with: - go-version: 1.17 - id: go - - name: Check out code into the Go module directory - uses: actions/checkout@main - - name: Running go tests with coverage - env: - GO111MODULE: on - run: make cover - - name: Send coverage - uses: shogo82148/actions-goveralls@v1 - with: - path-to-profile: coverage.out - lint: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go 1.17 + uses: actions/setup-go@v2 + with: + go-version: 1.17 + - name: Running go tests with coverage + env: + GO111MODULE: on + run: make cover + - name: Send coverage + uses: shogo82148/actions-goveralls@v1 + with: + path-to-profile: coverage.out + Lint: name: Lint checks runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Set up Go 1.17 uses: actions/setup-go@v2 with: go-version: 1.17 - id: go - - name: Check out code into the Go module directory - uses: actions/checkout@main - name: Download golangci-lint run: | wget https://github.com/golangci/golangci-lint/releases/download/v1.41.0/golangci-lint-1.41.0-linux-amd64.tar.gz