From a127f2af2881900d66e2a7f755b9fb958c90c51d Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Thu, 23 Jan 2025 13:40:13 +0100 Subject: [PATCH 1/4] add linux arm and arm64 build targets --- makefile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/makefile b/makefile index e0cd718..fe97564 100644 --- a/makefile +++ b/makefile @@ -2,6 +2,8 @@ VERSION=2.4 GITHASH=$(shell git rev-parse --short=8 HEAD) GO_LDFLAGS = -s -w -X 'main.Version=$(VERSION)' -X 'main.GitHash=$(GITHASH)' +CC_ARM ?= arm-linux-gnueabihf-gcc +CC_ARM64 ?= aarch64-linux-gnu-gcc export GOARCH ?= amd64 export CGO_ENABLED = 1 @@ -20,6 +22,20 @@ build_linux: mkdir -p _output/linux GOOS=linux go build -tags "sqlite_foreign_keys linux" -ldflags="$(GO_LDFLAGS)" -o _output/linux/yarr ./cmd/yarr +build_linux_arm: + mkdir -p _output/linux_arm + CC=$(CC_ARM) \ + GOOS=linux \ + GOARCH=arm GOARM=7 \ + go build -tags "sqlite_foreign_keys linux" -ldflags="$(GO_LDFLAGS)" -o _output/linux_arm/yarr ./cmd/yarr + +build_linux_arm64: + mkdir -p _output/linux_arm64 + CC=$(CC_ARM64) \ + GOOS=linux \ + GOARCH=arm64 \ + go build -tags "sqlite_foreign_keys linux" -ldflags="$(GO_LDFLAGS)" -o _output/linux_arm64/yarr ./cmd/yarr + build_windows: mkdir -p _output/windows go run ./cmd/generate_versioninfo -version "$(VERSION)" -outfile src/platform/versioninfo.rc From a5e7b02a8ab9d126c6341d45c4e1f90f246c4a2e Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Thu, 23 Jan 2025 14:44:15 +0100 Subject: [PATCH 2/4] don't use deprecated github actions --- .github/workflows/build.yml | 60 +++++++++++-------------------------- 1 file changed, 17 insertions(+), 43 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 66abc5d..3858ec9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: with: go-version: '^1.17' - name: Cache Go Modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} @@ -27,7 +27,7 @@ jobs: - name: "Build" run: make build_macos - name: Upload - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: macos path: _output/macos/yarr.app @@ -45,7 +45,7 @@ jobs: with: go-version: '^1.17' - name: Cache Go Modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} @@ -54,7 +54,7 @@ jobs: - name: "Build" run: make build_windows - name: Upload - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: windows path: _output/windows/yarr.exe @@ -72,7 +72,7 @@ jobs: with: go-version: '^1.17' - name: Cache Go Modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} @@ -81,7 +81,7 @@ jobs: - name: "Build" run: make build_linux - name: Upload - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: linux path: _output/linux/yarr @@ -92,16 +92,6 @@ jobs: if: ${{ !contains(github.ref, 'test') }} needs: [build_macos, build_windows, build_linux] steps: - - name: Create Release - uses: actions/create-release@v1 - id: create_release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - draft: true - prerelease: true - name: Download Artifacts uses: actions/download-artifact@v4.1.7 with: @@ -112,33 +102,17 @@ jobs: chmod u+x macos/Contents/MacOS/yarr chmod u+x linux/yarr - mv macos yarr.app && zip -r yarr-macos.zip yarr.app - mv windows/yarr.exe . && zip yarr-windows.zip yarr.exe - mv linux/yarr . && zip yarr-linux.zip yarr - - name: Upload MacOS - uses: actions/upload-release-asset@v1 + mv macos yarr.app && zip -r yarr-${GITHUB_REF_NAME}-macos64.zip yarr.app + ( cd windows && zip ../yarr-${GITHUB_REF_NAME}-windows64.zip yarr.exe ) + ( cd linux && zip ../yarr-${GITHUB_REF_NAME}-linux64.zip yarr ) + - name: Upload Release + uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./yarr-macos.zip - asset_name: yarr-${{ github.ref }}-macos64.zip - asset_content_type: application/zip - - name: Upload Windows - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./yarr-windows.zip - asset_name: yarr-${{ github.ref }}-windows64.zip - asset_content_type: application/zip - - name: Upload Linux - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./yarr-linux.zip - asset_name: yarr-${{ github.ref }}-linux64.zip - asset_content_type: application/zip + draft: true + prerelease: true + files: | + yarr-${{ github.ref_name }}-macos64.zip + yarr-${{ github.ref_name }}-windows64.zip + yarr-${{ github.ref_name }}-linux64.zip From 72b74b42d40c55f6da867b89dd4955c41e8a81ca Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Thu, 23 Jan 2025 14:46:00 +0100 Subject: [PATCH 3/4] add linux arm and arm64 builders --- .github/workflows/build.yml | 72 ++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3858ec9..2e79be1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -86,11 +86,75 @@ jobs: name: linux path: _output/linux/yarr + build_linux-arm: + name: Build for Linux ARM + runs-on: ubuntu-22.04 + steps: + - name: Install dependencies + run: > + sudo apt-get install -y + gcc-arm-linux-gnueabihf + libc6-armhf-cross + - name: "Checkout" + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: "Setup Go" + uses: actions/setup-go@v2 + with: + go-version: '^1.17' + - name: Cache Go Modules + uses: actions/cache@v4 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: "Build" + run: make build_linux_arm + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: linux_arm + path: _output/linux_arm/yarr + + build_linux-arm64: + name: Build for Linux ARM64 + runs-on: ubuntu-22.04 + steps: + - name: Install dependencies + run: > + sudo apt-get install -y + gcc-aarch64-linux-gnu + libc6-arm64-cross + - name: "Checkout" + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: "Setup Go" + uses: actions/setup-go@v2 + with: + go-version: '^1.17' + - name: Cache Go Modules + uses: actions/cache@v4 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: "Build" + run: make build_linux_arm64 + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: linux_arm64 + path: _output/linux_arm64/yarr + create_release: name: Create Release runs-on: ubuntu-latest if: ${{ !contains(github.ref, 'test') }} - needs: [build_macos, build_windows, build_linux] + needs: [build_macos, build_windows, build_linux, build_linux-arm, build_linux-arm64] steps: - name: Download Artifacts uses: actions/download-artifact@v4.1.7 @@ -101,10 +165,14 @@ jobs: ls -R chmod u+x macos/Contents/MacOS/yarr chmod u+x linux/yarr + chmod u+x linux_arm/yarr + chmod u+x linux_arm64/yarr mv macos yarr.app && zip -r yarr-${GITHUB_REF_NAME}-macos64.zip yarr.app ( cd windows && zip ../yarr-${GITHUB_REF_NAME}-windows64.zip yarr.exe ) ( cd linux && zip ../yarr-${GITHUB_REF_NAME}-linux64.zip yarr ) + ( cd linux_arm && zip ../yarr-${GITHUB_REF_NAME}-linux_arm.zip yarr ) + ( cd linux_arm64 && zip ../yarr-${GITHUB_REF_NAME}-linux_arm64.zip yarr ) - name: Upload Release uses: softprops/action-gh-release@v2 env: @@ -116,3 +184,5 @@ jobs: yarr-${{ github.ref_name }}-macos64.zip yarr-${{ github.ref_name }}-windows64.zip yarr-${{ github.ref_name }}-linux64.zip + yarr-${{ github.ref_name }}-linux_arm.zip + yarr-${{ github.ref_name }}-linux_arm64.zip From ba764dee8f7f82ecebd5f29a5461b98ffbaa0b23 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Thu, 23 Jan 2025 14:50:21 +0100 Subject: [PATCH 4/4] upload artifacts to push actions too --- .github/workflows/build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2e79be1..65ef567 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,8 +1,6 @@ name: build -on: - push: - tags: ['v*', 'test*'] +on: push jobs: build_macos: @@ -153,7 +151,7 @@ jobs: create_release: name: Create Release runs-on: ubuntu-latest - if: ${{ !contains(github.ref, 'test') }} + if: ${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'test') }} needs: [build_macos, build_windows, build_linux, build_linux-arm, build_linux-arm64] steps: - name: Download Artifacts