BUX-624/ Changed Default port #258
Workflow file for this run
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: Go | |
permissions: | |
contents: write | |
on: | |
push: | |
tags: | |
- '*' | |
branches: [ master,main ] | |
pull_request: | |
branches: [ master,main ] | |
jobs: | |
golangci: | |
name: lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. | |
version: latest | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go from go.mod | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
- name: Clean test cache | |
run: go clean -testcache | |
- name: Build | |
run: go build -v ./... | |
- name: Tests | |
run: go test -v ./... -race | |
build-darwin-artifacts: | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: [ golangci,test ] | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- run: git fetch --force --tags | |
- uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
- uses: goreleaser/goreleaser-action@v4 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: -f release/.goreleaser-darwin.yml release --clean --debug | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload | |
uses: actions/upload-artifact@v3 | |
with: | |
name: bin-darwin | |
path: dist/${{ github.event.repository.name }}_*.tar.gz | |
release-linux: | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: [ build-darwin-artifacts ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Dockerhub repo based on var | |
if: vars.DOCKERHUB_REPO != null | |
run: | | |
echo "DOCKERHUB_REPO=${{vars.DOCKERHUB_REPO}}" >> $GITHUB_ENV | |
- name: Default Dockerhub repo to on project name | |
if: vars.DOCKERHUB_REPO == null | |
run: | | |
echo "DOCKERHUB_REPO=$(basename ${GITHUB_REPOSITORY})" >> $GITHUB_ENV | |
- name: Setup Dockerhub owner based on var | |
if: vars.DOCKERHUB_OWNER != null | |
run: | | |
echo "DOCKERHUB_OWNER=${{vars.DOCKERHUB_OWNER}}" >> $GITHUB_ENV | |
- name: Default Dockerhub owner to dockerhub username | |
if: vars.DOCKERHUB_OWNER == null | |
run: | | |
echo "DOCKERHUB_OWNER=${{secrets.DOCKERHUB_USERNAME}}" >> $GITHUB_ENV | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- run: git fetch --force --tags | |
- uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
- name: Make directory for darwin bin | |
run: | | |
mkdir -p ./release/artifacts/darwin | |
- name: Download Darwin binaries | |
uses: actions/download-artifact@v3 | |
with: | |
name: bin-darwin | |
path: ./release/artifacts/darwin | |
# Uncomment if you need CGO_ENABLED=1 | |
# - name: Install cross-compiler for linux/arm64 | |
# run: sudo apt-get -y install gcc-aarch64-linux-gnu | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Prepare README for dockerhub | |
run: | | |
envsubst < ./release/README.DOCKER.md > ./release/artifacts/README.DOCKER.md | |
- name: Go Release | |
uses: goreleaser/goreleaser-action@v4 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: -f release/.goreleaser-linux.yml release --clean --debug | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DOCKERHUB_USERNAME: ${{ env.DOCKERHUB_OWNER }} | |
DOCKERHUB_REPONAME: ${{ env.DOCKERHUB_REPO }} | |
SOURCE_URL: ${{ github.event.repository.url }} | |
- name: Docker Hub Description | |
uses: peter-evans/dockerhub-description@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
short-description: ${{ github.event.repository.description }} | |
repository: ${{ env.DOCKERHUB_OWNER }}/${{ env.DOCKERHUB_REPO }} | |
readme-filepath: ./release/artifacts/README.DOCKER.md |