From 26297269955c87787b0602fe4a069c3c39e3dd6d Mon Sep 17 00:00:00 2001 From: Artem Suprun Date: Sun, 12 Jan 2025 04:07:39 +0200 Subject: [PATCH 1/6] feat: github action to build --- .github/workflows/build.yml | 71 +++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4066cc8 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,71 @@ +name: Build +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-x86_64: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.23' + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y libglib2.0-dev libgtk-3-dev libwayland-dev + + - name: Build the app for x86_64 + run: | + mkdir -p .bin + export GO111MODULE=on + export GOBIN=$(pwd)/.bin + go build -pgo default.pgo -tags wayland -trimpath -ldflags="-s -w" -o $GOBIN/play-timer-x86_64 ./cmd/main.go + + - name: Verify build output for x86_64 + run: | + if [ ! -f .bin/play-timer-x86_64 ]; then + echo "Build failed: play-timer-x86_64 binary not found" + exit 1 + fi + + build-aarch64: + runs-on: ubuntu-22.04-arm64 + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.23' + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y libglib2.0-dev libgtk-3-dev libwayland-dev + + - name: Build the app for aarch64 + run: | + mkdir -p .bin + export GO111MODULE=on + export GOBIN=$(pwd)/.bin + go build -pgo default.pgo -tags wayland -trimpath -ldflags="-s -w" -o $GOBIN/play-timer-aarch64 ./cmd/main.go + + - name: Verify build output for aarch64 + run: | + if [ ! -f .bin/play-timer-aarch64 ]; then + echo "Build failed: play-timer-aarch64 binary not found" + exit 1 + fi From f708124ad7e8b40b8fff6ac47b8e4fb70a86d7f5 Mon Sep 17 00:00:00 2001 From: Artem Suprun Date: Sun, 12 Jan 2025 04:11:11 +0200 Subject: [PATCH 2/6] bugfix: hotfix --- .github/workflows/build.yml | 52 +++++++++---------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4066cc8..b24a19f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,40 +8,12 @@ on: - main jobs: - build-x86_64: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.23' - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y libglib2.0-dev libgtk-3-dev libwayland-dev - - - name: Build the app for x86_64 - run: | - mkdir -p .bin - export GO111MODULE=on - export GOBIN=$(pwd)/.bin - go build -pgo default.pgo -tags wayland -trimpath -ldflags="-s -w" -o $GOBIN/play-timer-x86_64 ./cmd/main.go - - - name: Verify build output for x86_64 - run: | - if [ ! -f .bin/play-timer-x86_64 ]; then - echo "Build failed: play-timer-x86_64 binary not found" - exit 1 - fi - - build-aarch64: - runs-on: ubuntu-22.04-arm64 - + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, ubuntu-22.04-arm64] + arch: [x86_64, arm64] steps: - name: Checkout code uses: actions/checkout@v3 @@ -54,18 +26,18 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y libglib2.0-dev libgtk-3-dev libwayland-dev + sudo apt-get install -y libglib2.0-dev libgtk-3-dev libwayland-dev libasound2-dev libgirepository1.0-dev libgraphene-1.0-dev - - name: Build the app for aarch64 + - name: Build the app run: | mkdir -p .bin export GO111MODULE=on export GOBIN=$(pwd)/.bin - go build -pgo default.pgo -tags wayland -trimpath -ldflags="-s -w" -o $GOBIN/play-timer-aarch64 ./cmd/main.go + go build -pgo default.pgo -tags wayland -trimpath -ldflags="-s -w" -o $GOBIN/play-timer-${{ matrix.arch }} ./cmd/main.go - - name: Verify build output for aarch64 + - name: Verify build output run: | - if [ ! -f .bin/play-timer-aarch64 ]; then - echo "Build failed: play-timer-aarch64 binary not found" + if [ ! -f .bin/play-timer-${{ matrix.arch }} ]; then + echo "Build failed: play-timer-${{ matrix.arch }} binary not found" exit 1 fi From bcfbe8bb4e7ae652b27384e639694999f6dc239d Mon Sep 17 00:00:00 2001 From: Artem Suprun Date: Sun, 12 Jan 2025 04:14:55 +0200 Subject: [PATCH 3/6] bugfix: hotfix --- .github/workflows/build.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b24a19f..bf489af 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,38 +6,35 @@ on: pull_request: branches: - main - jobs: build: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, ubuntu-22.04-arm64] - arch: [x86_64, arm64] + include: + - os: ubuntu-latest + arch: x86_64 + - os: ubuntu-latest-arm64 + arch: arm64 steps: - name: Checkout code uses: actions/checkout@v3 - - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.23' - - name: Install dependencies run: | sudo apt-get update sudo apt-get install -y libglib2.0-dev libgtk-3-dev libwayland-dev libasound2-dev libgirepository1.0-dev libgraphene-1.0-dev - - name: Build the app run: | mkdir -p .bin export GO111MODULE=on export GOBIN=$(pwd)/.bin go build -pgo default.pgo -tags wayland -trimpath -ldflags="-s -w" -o $GOBIN/play-timer-${{ matrix.arch }} ./cmd/main.go - - name: Verify build output run: | if [ ! -f .bin/play-timer-${{ matrix.arch }} ]; then echo "Build failed: play-timer-${{ matrix.arch }} binary not found" exit 1 - fi From dfb0310b8ca92e8298492b7b1b4a3b0be4deb022 Mon Sep 17 00:00:00 2001 From: Artem Suprun Date: Sun, 12 Jan 2025 04:21:19 +0200 Subject: [PATCH 4/6] bugfix: hotfix --- .github/workflows/build.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bf489af..3abbfa4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,7 @@ on: pull_request: branches: - main + jobs: build: runs-on: ${{ matrix.os }} @@ -16,23 +17,28 @@ jobs: arch: x86_64 - os: ubuntu-latest-arm64 arch: arm64 + steps: - name: Checkout code uses: actions/checkout@v3 + - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.23' + - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y libglib2.0-dev libgtk-3-dev libwayland-dev libasound2-dev libgirepository1.0-dev libgraphene-1.0-dev + sudo apt-get install -y libglib2.0-dev libgtk-3-dev libgtk-4-dev libadwaita-1-dev libwayland-dev libasound2-dev libgirepository1.0-dev libgraphene-1.0-dev + - name: Build the app run: | mkdir -p .bin export GO111MODULE=on export GOBIN=$(pwd)/.bin go build -pgo default.pgo -tags wayland -trimpath -ldflags="-s -w" -o $GOBIN/play-timer-${{ matrix.arch }} ./cmd/main.go + - name: Verify build output run: | if [ ! -f .bin/play-timer-${{ matrix.arch }} ]; then From 65edc8c72bd58562d000f615536db755735fb057 Mon Sep 17 00:00:00 2001 From: Artem Suprun Date: Sun, 12 Jan 2025 04:42:37 +0200 Subject: [PATCH 5/6] feat: libadwaita 1.6 --- .github/workflows/build.yml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3abbfa4..49b43a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,28 +17,40 @@ jobs: arch: x86_64 - os: ubuntu-latest-arm64 arch: arm64 - + steps: - name: Checkout code uses: actions/checkout@v3 - + - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.23' - + - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y libglib2.0-dev libgtk-3-dev libgtk-4-dev libadwaita-1-dev libwayland-dev libasound2-dev libgirepository1.0-dev libgraphene-1.0-dev - + sudo apt-get install -y meson ninja-build libglib2.0-dev libgtk-3-dev libgtk-4-dev libadwaita-1-dev libwayland-dev libasound2-dev libgirepository1.0-dev libgraphene-1.0-dev + + - name: Build libadwaita-1.6.2 + run: | + wget https://download.gnome.org/sources/libadwaita/1.6/libadwaita-1.6.2.tar.xz + echo "321649c7428a720b8cd3a88f659002e0 libadwaita-1.6.2.tar.xz" | md5sum -c - + tar -xf libadwaita-1.6.2.tar.xz + cd libadwaita-1.6.2 + mkdir build + cd build + meson setup --prefix=/usr --buildtype=release .. + ninja + sudo ninja install + - name: Build the app run: | mkdir -p .bin export GO111MODULE=on export GOBIN=$(pwd)/.bin go build -pgo default.pgo -tags wayland -trimpath -ldflags="-s -w" -o $GOBIN/play-timer-${{ matrix.arch }} ./cmd/main.go - + - name: Verify build output run: | if [ ! -f .bin/play-timer-${{ matrix.arch }} ]; then From 22860d6dc25fb68a1b78b058d01d1060513b226a Mon Sep 17 00:00:00 2001 From: Artem Suprun Date: Sun, 12 Jan 2025 05:06:16 +0200 Subject: [PATCH 6/6] feat: build in container --- .github/workflows/build.yml | 58 ++++++++++--------------------------- Dockerfile | 17 +++++++++++ 2 files changed, 32 insertions(+), 43 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 49b43a3..efed201 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,53 +6,25 @@ on: pull_request: branches: - main - jobs: build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: ubuntu-latest - arch: x86_64 - - os: ubuntu-latest-arm64 - arch: arm64 - + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.23' - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y meson ninja-build libglib2.0-dev libgtk-3-dev libgtk-4-dev libadwaita-1-dev libwayland-dev libasound2-dev libgirepository1.0-dev libgraphene-1.0-dev - - - name: Build libadwaita-1.6.2 + + - name: Build Docker image run: | - wget https://download.gnome.org/sources/libadwaita/1.6/libadwaita-1.6.2.tar.xz - echo "321649c7428a720b8cd3a88f659002e0 libadwaita-1.6.2.tar.xz" | md5sum -c - - tar -xf libadwaita-1.6.2.tar.xz - cd libadwaita-1.6.2 - mkdir build - cd build - meson setup --prefix=/usr --buildtype=release .. - ninja - sudo ninja install - - - name: Build the app + docker build -t play-timer:latest . + + - name: Extract binary run: | - mkdir -p .bin - export GO111MODULE=on - export GOBIN=$(pwd)/.bin - go build -pgo default.pgo -tags wayland -trimpath -ldflags="-s -w" -o $GOBIN/play-timer-${{ matrix.arch }} ./cmd/main.go - - - name: Verify build output - run: | - if [ ! -f .bin/play-timer-${{ matrix.arch }} ]; then - echo "Build failed: play-timer-${{ matrix.arch }} binary not found" - exit 1 + docker create --name extract play-timer:latest + docker cp extract:/app/.bin/play-timer play-timer-x86_64 + docker rm extract + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: play-timer-x86_64 + path: play-timer-x86_64 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ab63fe8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM archlinux:latest +WORKDIR /app + +RUN pacman -Syu --noconfirm && \ + pacman -S --noconfirm go meson ninja glib2 gtk3 gtk4 libadwaita wayland alsa-lib pulse-native-provider gobject-introspection graphene gcc pkgconf + +COPY cmd ./cmd +COPY internal ./internal +COPY misc ./misc +COPY go.* *.go default.pgo ./ + +ENV GO111MODULE=on +ENV CGO_ENABLED=1 + +RUN mkdir -p .bin +RUN go mod download +RUN go build -pgo default.pgo -tags wayland -trimpath -ldflags="-s -w" -o .bin/play-timer ./cmd/main.go