Fix ldflags again #7
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: Build Binary | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
go-version: [ '1.22.5' ] | |
os-flavor: [ 'linux' ] | |
architecture: [ 'amd64', 'arm', 'arm64' ] | |
path-to-build: [ './cmd/email-random' ] | |
steps: | |
- uses: actions/checkout@v4 | |
# Caching is enabled by default when using setup-go | |
- name: Setup Go ${{ matrix.go-version }} | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.go-version }} | |
# You can test your matrix by printing the current Go version | |
- name: Display Go version | |
run: go version | |
- name: Get dependencies | |
run: go get ./... | |
- name: Print the list of files | |
run: ls -lsh . | |
- name: Print the branch/tag name and the commit hash | |
run: | | |
echo "Ref: ${{ github.ref }}; Commit: $GITHUB_SHA" | |
- name: Build binary for the required OS and architecture | |
run: | | |
OUTPUT_FILE_NAME="./$(basename ${{ matrix.path-to-build }})-${{ matrix.os-flavor }}-${{ matrix.architecture }}" | |
GOOS=${{ matrix.os-flavor }} GOARCH=${{ matrix.architecture }} \ | |
-ldflags="-X \"github.com/icyflame/kindle-my-clippings-parser/internal/env.Version=${{ github.ref }} $GITHUB_SHA\"" \ | |
go build $LDFLAGS -o $OUTPUT_FILE_NAME ${{ matrix.path-to-build }} | |
sha256sum $OUTPUT_FILE_NAME > $OUTPUT_FILE_NAME.checksum | |
- name: Print file output of the binary file that was built | |
run: | | |
file ./$(basename ${{ matrix.path-to-build }})-${{ matrix.os-flavor }}-${{ matrix.architecture }} | |
file ./$(basename ${{ matrix.path-to-build }})-${{ matrix.os-flavor }}-${{ matrix.architecture }}.checksum | |
- name: Upload binaries if a tag was pushed | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
./$(basename ${{ matrix.path-to-build }})-${{ matrix.os-flavor }}-${{ matrix.architecture }} | |
./$(basename ${{ matrix.path-to-build }})-${{ matrix.os-flavor }}-${{ matrix.architecture }}.checksum |