Merge pull request #24 from JenswBE/dependabot/github_actions/golangc… #45
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: Test and build | |
on: | |
push: | |
branches: [main] | |
tags: | |
- "*" | |
permissions: | |
contents: write | |
env: | |
GO_VERSION: "1.22" | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
check-latest: true | |
- name: Pull common linter configs | |
run: wget -O .golangci.yml https://raw.githubusercontent.com/JenswBE/setup/main/programming_configs/golang/.golangci.yml | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v5 | |
with: | |
version: latest | |
args: >- | |
--timeout=5m | |
--disable goerr113,noctx,wrapcheck | |
--exclude 'func name will be used as send.SendEmail' | |
- name: Start E2E services | |
run: | | |
docker compose -f test/docker-compose.yml up -d | |
- name: Run tests | |
run: | | |
go test ./... | |
- name: Build binaries | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
BIN_NAME='smtp-cli_${{ github.ref_name }}_${GOOS:?}_${GOARCH:?}${GOARM_PREFIX}${GOARM}' | |
DEFAULT_ARGS="-ldflags='-X main.Version=${{ github.ref_name }} -extldflags=-static'" | |
export CGO_ENABLED=0 | |
export GOOS=linux | |
GOARCH=amd64 bash -c "go build ${DEFAULT_ARGS:?} -o ${BIN_NAME:?}" | |
GOARCH=arm GOARM_PREFIX=v GOARM=6 bash -c "go build ${DEFAULT_ARGS:?} -o ${BIN_NAME:?}" | |
GOARCH=arm GOARM_PREFIX=v GOARM=7 bash -c "go build ${DEFAULT_ARGS:?} -o ${BIN_NAME:?}" | |
GOARCH=arm64 bash -c "go build ${DEFAULT_ARGS:?} -o ${BIN_NAME:?}" | |
- name: Create release on tag | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: softprops/action-gh-release@v2 | |
with: | |
fail_on_unmatched_files: true | |
generate_release_notes: true | |
files: | | |
smtp-cli_${{ github.ref_name }}_linux_amd64 | |
smtp-cli_${{ github.ref_name }}_linux_armv6 | |
smtp-cli_${{ github.ref_name }}_linux_armv7 | |
smtp-cli_${{ github.ref_name }}_linux_arm64 |