Cleanup #171
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: Build | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- "*" | |
jobs: | |
linux_and_windows: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.22.2 | |
- name: git cleanup | |
run: git clean -f | |
- name: Unit tests | |
run: | | |
go test -v -race ./... -covermode=atomic # Run all the tests with the race detector enabled | |
- name: Static analysis | |
run: | | |
go vet ./... # go vet is the official Go static analyzer | |
- name: Cyclomatic complexity | |
run: | | |
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest | |
/home/runner/go/bin/gocyclo -over 19 main.go pkg # forbid code with huge/complex functions | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
version: latest | |
args: release --parallelism 1 --snapshot --clean | |
- name: Test Binary is Runnable | |
run: "dist/build_win_and_linux_linux_amd64_v1/komocli --help" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: binaries | |
path: dist/ | |
retention-days: 1 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v4 | |
with: | |
# version: latest | |
# skip-go-installation: true | |
skip-pkg-cache: true | |
skip-build-cache: true | |
# args: --timeout=15m | |
mac_with_signing: | |
runs-on: macos-latest | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.22.2 | |
- name: Prepare keys | |
env: | |
CERT: certificate.p12 | |
CERT_PASSWORD: "" | |
MY_KEYCHAIN: build.keychain | |
MY_KEYCHAIN_PASSWORD: ${{ secrets.CERTIFICATE_ID }} | |
IDENTITY_CERTIFICATE: "Developer ID Application: Komodor Automation LTD (F584U99DLC)" | |
run: | | |
echo Decode the certificate | |
echo ${{ secrets.CERTIFICATE_BASE64 }} | base64 --decode > $CERT | |
# default again user login keychain | |
security list-keychains -d user -s login.keychain | |
# Create temp keychain | |
security create-keychain -p "$MY_KEYCHAIN_PASSWORD" "$MY_KEYCHAIN" | |
# Append temp keychain to the user domain | |
security list-keychains -d user -s "$MY_KEYCHAIN" $(security list-keychains -d user | sed s/\"//g) | |
# Remove relock timeout | |
security set-keychain-settings "$MY_KEYCHAIN" | |
# Unlock keychain | |
security unlock-keychain -p "$MY_KEYCHAIN_PASSWORD" "$MY_KEYCHAIN" | |
# Add certificate to keychain | |
security import $CERT -k "$MY_KEYCHAIN" -P "$CERT_PASSWORD" -A -T "/usr/bin/codesign" | |
# Enable codesigning from a non user interactive shell | |
security set-key-partition-list -S apple-tool:,apple:, -t private -s -k "$MY_KEYCHAIN_PASSWORD" -D "${IDENTITY_CERTIFICATE}" "$MY_KEYCHAIN" | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
version: latest | |
args: release --config .goreleaser-mac.yml --parallelism 1 --snapshot --clean | |
env: | |
MACOS_NOTARY_APPLE_ID: ${{ secrets.APPLE_ID_USERNAME }} | |
MACOS_NOTARY_TEAM_ID: ${{ secrets.APPLE_NOTARY_TEAM_ID }} | |
MACOS_NOTARY_PASSWORD: ${{ secrets.APP_SPECIFIC_PASSWORD }} | |
CERTIFICATE_ID: ${{ secrets.CERTIFICATE_ID }} | |
- name: Test Binary is Signed | |
run: | | |
cat notarytool.log | |
echo =============================== | |
codesign -dv dist/build_macos_darwin_arm64/komocli | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: binaries-mac | |
path: dist/ | |
retention-days: 1 |