update readme #51
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: pipeline | |
on: [push] | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19 | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: latest | |
args: --timeout=30m0s | |
skip-cache: true | |
test: | |
needs: lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19 | |
- name: Run tests | |
run: make test-coverage | |
- name: Upload Coverage report to CodeCov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{secrets.CODECOV_TOKEN}} | |
file: ./coverage.txt | |
build: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19 | |
- name: Build | |
run: make build | |
- name: Cache the build artifacts | |
if: contains(github.ref, 'refs/tags/') | |
uses: actions/cache@v3 | |
with: | |
path: build | |
key: build-${{ hashFiles('**/*', '!build', '!.git') }} | |
restore-keys: | | |
build- | |
release: | |
if: contains(github.ref, 'refs/tags/') | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Restore build artifacts | |
uses: actions/cache@v3 | |
with: | |
path: build | |
key: build-${{ hashFiles('**/*', '!build', '!.git') }} | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
draft: false | |
files: | | |
build/telegram-logger-linux-amd64 | |
build/telegram-logger-windows-amd64.exe | |
build/telegram-logger-darwin-amd64 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
push-to-dockerhub: | |
if: github.ref == 'refs/heads/master' || contains(github.ref, 'refs/tags/') | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and Push (latest) | |
if: github.ref == 'refs/heads/master' | |
uses: docker/build-push-action@v3 | |
with: | |
# context: . | |
push: true | |
tags: psyb0t/telegram-logger:latest | |
- name: Get Release Version | |
if: contains(github.ref, 'refs/tags/') | |
run: | | |
RELEASE_VERSION=${GITHUB_REF#refs/*/} | |
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV | |
- name: Build and Push New Release | |
if: contains(github.ref, 'refs/tags/') | |
uses: docker/build-push-action@v3 | |
with: | |
# context: . | |
push: true | |
tags: psyb0t/telegram-logger:${{env.RELEASE_VERSION}} |