From a42e40b091891e4aaa915e808803ab2708d6c301 Mon Sep 17 00:00:00 2001 From: Maxence Maireaux Date: Wed, 21 Dec 2022 15:28:29 +0100 Subject: [PATCH] ci: Update GoRelease for MacOS Build (#391) * ci: Update GoRelease for MacOS Build * ci: Add MacOS Runner --- .../workflows/template_goreleaser-build.yaml | 30 +++++---- .../template_goreleaser-release.yaml | 31 +++++---- .goreleaser-darwin.yml | 64 +++++++++++++++++++ .goreleaser.yml | 33 ---------- 4 files changed, 99 insertions(+), 59 deletions(-) create mode 100644 .goreleaser-darwin.yml diff --git a/.github/workflows/template_goreleaser-build.yaml b/.github/workflows/template_goreleaser-build.yaml index a159e1756..547bcee24 100644 --- a/.github/workflows/template_goreleaser-build.yaml +++ b/.github/workflows/template_goreleaser-build.yaml @@ -12,7 +12,10 @@ on: jobs: goreleaser: name: GoReleaser Build - runs-on: ubuntu-latest + strategy: + matrix: + os: [ ubuntu-latest, macos-latest ] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 @@ -24,25 +27,26 @@ jobs: with: name: control-dist path: cmd/control/ - - name: OSXCross for CGO Support - run: | - mkdir ../../osxcross - git clone https://github.com/plentico/osxcross-target.git ../../osxcross/target - - name: Downgrade libssl - run: | - sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32 - echo 'deb http://security.ubuntu.com/ubuntu bionic-security main' | sudo tee -a /etc/apt/sources.list - sudo apt update && apt-cache policy libssl1.0-dev - sudo apt-get install libssl1.0-dev - run: sudo apt install gcc-aarch64-linux-gnu gcc-mingw-w64 -y - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 + if: ${{ matrix.os == 'ubuntu-latest' }} + - name: Run GoReleaser for Linux + if: ${{ matrix.os == 'ubuntu-latest' }} + uses: goreleaser/goreleaser-action@v4 with: version: latest args: build --parallelism 4 --rm-dist --skip-validate --snapshot env: GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }} SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_OSS }} + - name: Run GoReleaser for MacOS + if: ${{ matrix.os == 'macos-latest' }} + uses: goreleaser/goreleaser-action@v4 + with: + version: latest + args: build -f .goreleaser-darwin.yml --parallelism 4 --rm-dist --skip-validate --snapshot + env: + GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }} + SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_OSS }} - uses: actions/upload-artifact@v2 with: name: dist diff --git a/.github/workflows/template_goreleaser-release.yaml b/.github/workflows/template_goreleaser-release.yaml index c3737aa62..0fb9dc07e 100644 --- a/.github/workflows/template_goreleaser-release.yaml +++ b/.github/workflows/template_goreleaser-release.yaml @@ -15,7 +15,10 @@ on: jobs: goreleaser: name: GoReleaser Build - runs-on: ubuntu-latest + strategy: + matrix: + os: [ ubuntu-latest, macos-latest ] + runs-on: ${{ matrix.os }} env: DOCKER_CLI_EXPERIMENTAL: "enabled" steps: @@ -31,17 +34,8 @@ jobs: with: name: control-dist path: cmd/control/ - - name: OSXCross for CGO Support - run: | - mkdir ../../osxcross - git clone https://github.com/plentico/osxcross-target.git ../../osxcross/target - - name: Downgrade libssl - run: | - sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32 - echo 'deb http://security.ubuntu.com/ubuntu bionic-security main' | sudo tee -a /etc/apt/sources.list - sudo apt update && apt-cache policy libssl1.0-dev - sudo apt-get install libssl1.0-dev - run: sudo apt install gcc-aarch64-linux-gnu gcc-mingw-w64 -y + if: ${{ matrix.os == 'ubuntu-latest' }} - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx @@ -52,15 +46,26 @@ jobs: registry: ghcr.io username: "NumaryBot" password: ${{ secrets.NUMARY_GITHUB_TOKEN }} - - name: Run GoReleaser + - name: Run GoReleaser for Linux + if: ${{ matrix.os == 'ubuntu-latest' }} env: GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }} FURY_TOKEN: ${{ secrets.FURY_TOKEN }} SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_OSS }} - uses: goreleaser/goreleaser-action@v2 + uses: goreleaser/goreleaser-action@v4 with: version: latest args: release --rm-dist + - name: Run GoReleaser for MacOS + if: ${{ matrix.os == 'macos-latest' }} + env: + GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }} + FURY_TOKEN: ${{ secrets.FURY_TOKEN }} + SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_OSS }} + uses: goreleaser/goreleaser-action@v4 + with: + version: latest + args: release -f .goreleaser-darwin.yml --rm-dist - uses: actions/cache@v2 with: path: | diff --git a/.goreleaser-darwin.yml b/.goreleaser-darwin.yml new file mode 100644 index 000000000..7054c4f8b --- /dev/null +++ b/.goreleaser-darwin.yml @@ -0,0 +1,64 @@ +project_name: numary +env: + - GO111MODULE=on + - GOPROXY=https://proxy.golang.org +before: + hooks: + - go mod download + +builds: + - binary: numary + id: numary_darwin + ldflags: + - -X github.com/numary/ledger/cmd.BuildDate={{ .Date }} + - -X github.com/numary/ledger/cmd.Version={{ .Version }} + - -X github.com/numary/ledger/cmd.Commit={{ .ShortCommit }} + - -X github.com/numary/ledger/cmd.DefaultSegmentWriteKey={{ .Env.SEGMENT_WRITE_KEY }} + - -s + env: + - CGO_ENABLED=1 + goos: + - darwin + goarch: + - amd64 + - arm64 + flags: + - -tags=json1 + +archives: + - id: "numary" + builds: + - numary_darwin + format: tar.gz + format_overrides: + - goos: windows + format: zip + name_template: "{{.ProjectName}}_{{.Version}}_{{.Os}}-{{.Arch}}" + replacements: + amd64: 64bit + 386: 32bit + arm: ARM + arm64: ARM64 + darwin: macOS + linux: Linux + windows: Windows + + +checksum: + name_template: 'checksums.txt' + +snapshot: + name_template: "{{ .Tag }}" + +brews: + - tap: + owner: formancehq + name: homebrew-tap + name: numary + folder: Formula + homepage: https://formance.com + skip_upload: auto + test: | + system "#{bin}/numary version" + install: | + bin.install "numary" diff --git a/.goreleaser.yml b/.goreleaser.yml index 1429e0eb4..51beb5193 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -56,32 +56,12 @@ builds: - arm64 flags: - -tags=json1,netgo - - binary: numary - id: numary_darwin - ldflags: - - -X github.com/numary/ledger/cmd.BuildDate={{ .Date }} - - -X github.com/numary/ledger/cmd.Version={{ .Version }} - - -X github.com/numary/ledger/cmd.Commit={{ .ShortCommit }} - - -X github.com/numary/ledger/cmd.DefaultSegmentWriteKey={{ .Env.SEGMENT_WRITE_KEY }} - - -s - env: - - CGO_ENABLED=1 - - CC=/home/runner/work/osxcross/target/bin/o64-clang - - CXX=/home/runner/work/osxcross/target/bin/o64-clang++ - goos: - - darwin - goarch: - - amd64 - - arm64 - flags: - - -tags=json1 archives: - id: "numary" builds: - numary_linux_amd64 - numary_linux_arm64 - - numary_darwin - numary_windows format: tar.gz format_overrides: @@ -135,19 +115,6 @@ release: - Read the [documentation](https://docs.numary.com/oss/ledger/get-started/installation) - Join our [Discord server](https://discord.gg/xyHvcbzk4w) -brews: - - tap: - owner: formancehq - name: homebrew-tap - name: numary - folder: Formula - homepage: https://formance.com - skip_upload: auto - test: | - system "#{bin}/numary version" - install: | - bin.install "numary" - nfpms: - id: packages package_name: numary