From a4aa1bd8d3f4639b5871153643190dc78a2bf3de Mon Sep 17 00:00:00 2001 From: devgianlu Date: Sun, 20 Oct 2024 18:41:28 +0200 Subject: [PATCH] ci: use Docker to build release --- .github/workflows/release.yml | 140 +++++----------------------------- 1 file changed, 17 insertions(+), 123 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c108977..7a1f0f8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,105 +8,21 @@ permissions: contents: write jobs: - build-deps: - runs-on: ubuntu-20.04 - strategy: - matrix: - include: - - target: x86-64-linux-gnu - cc: gcc - - target: arm-rpi-linux-gnueabihf - cc: arm-rpi-linux-gnueabihf-gcc - - target: arm-linux-gnueabihf - cc: arm-linux-gnueabihf-gcc - - target: aarch64-linux-gnu - cc: aarch64-linux-gnu-gcc - env: - CC: ${{ matrix.cc }} - steps: - - name: Install toolchain for ${{ matrix.target }} - if: ${{ matrix.target != 'arm-rpi-linux-gnueabihf' }} - run: sudo apt-get update && sudo apt-get install -y gcc-${{ matrix.target }} - - - name: Install custom toolchain for ${{ matrix.target }} - if: ${{ matrix.target == 'arm-rpi-linux-gnueabihf' }} - run: | - wget https://github.com/devgianlu/rpi-toolchain/releases/download/v1/arm-rpi-linux-gnueabihf.tar.gz - sudo tar -C /usr --strip-components=1 -xzf arm-rpi-linux-gnueabihf.tar.gz - - - name: Download alsa-lib sources - working-directory: /tmp - run: | - wget http://www.alsa-project.org/files/pub/lib/alsa-lib-1.2.10.tar.bz2 - tar -xvf alsa-lib-1.2.10.tar.bz2 - - - name: Compile alsa-lib for ${{ matrix.target }} - working-directory: /tmp - run: | - cd alsa-lib-1.2.10 - ./configure --enable-shared=yes --enable-static=no --with-pic \ - --host=${{ matrix.target }} --prefix=/tmp/deps/${{ matrix.target }} - make - sudo make install - - - name: Download libogg sources - working-directory: /tmp - run: | - wget https://downloads.xiph.org/releases/ogg/libogg-1.3.5.tar.xz - tar -xvf libogg-1.3.5.tar.xz - - - name: Compile libogg for ${{ matrix.target }} - working-directory: /tmp - run: | - cd libogg-1.3.5 - ./configure --host=${{ matrix.target }} --prefix=/tmp/deps/${{ matrix.target }} - make - sudo make install - - - name: Download libvorbis sources - working-directory: /tmp - run: | - wget https://downloads.xiph.org/releases/vorbis/libvorbis-1.3.7.tar.xz - tar -xvf libvorbis-1.3.7.tar.xz - - - name: Compile libvorbis for ${{ matrix.target }} - working-directory: /tmp - run: | - cd libvorbis-1.3.7 - ./configure --host=${{ matrix.target }} --prefix=/tmp/deps/${{ matrix.target }} - make - sudo make install - - - name: Package dependencies - run: mkdir /tmp/out && tar -C /tmp/deps -cvf /tmp/out/${{ matrix.target }}.tar ${{ matrix.target }} - - - name: Upload compiled dependencies - uses: actions/upload-artifact@v3 - with: - name: deps - path: /tmp/out - retention-days: 1 - build: - runs-on: ubuntu-20.04 - needs: - - build-deps + runs-on: ubuntu-24.04 strategy: matrix: include: - target: x86-64-linux-gnu goarch: amd64 - goamd64: v1 cc: gcc tar: linux_x86_64 - target: arm-rpi-linux-gnueabihf goarch: arm - goarm: 6 cc: arm-rpi-linux-gnueabihf-gcc tar: linux_armv6_rpi - target: arm-linux-gnueabihf goarch: arm - goarm: 6 cc: arm-linux-gnueabihf-gcc tar: linux_armv6 - target: aarch64-linux-gnu @@ -120,45 +36,23 @@ jobs: - run: git fetch --force --tags - - name: Set up Golang - uses: actions/setup-go@v4 - with: - go-version: '1.22.2' - - - name: Download compiled dependencies - uses: actions/download-artifact@v3 - with: - name: deps - path: /tmp/deps - - - name: Unpack compiled dependencies - run: sudo mkdir /tmp/deps/${{ matrix.target }} && sudo tar -C /tmp/deps/${{ matrix.target }} --strip-components=1 -xvf /tmp/deps/${{ matrix.target }}.tar - - - name: Install build dependencies - if: ${{ matrix.target != 'arm-rpi-linux-gnueabihf' }} - run: sudo apt-get update && sudo apt-get install -y gcc-${{ matrix.target }} - - - name: Install build dependencies for arm-rpi-linux-gnueabihf - if: ${{ matrix.target == 'arm-rpi-linux-gnueabihf' }} - working-directory: /tmp - run: | - wget https://github.com/devgianlu/rpi-toolchain/releases/download/v1/arm-rpi-linux-gnueabihf.tar.gz - sudo tar -C /usr --strip-components=1 -xzf arm-rpi-linux-gnueabihf.tar.gz - - - name: Build with Go - env: - CGO_ENABLED: 1 - GOOS: ${{ matrix.goos }} - GOARCH: ${{ matrix.goarch }} - GOARM: ${{ matrix.goarm }} - GOAMD64: ${{ matrix.goamd64 }} - CC: ${{ matrix.cc }} - PKG_CONFIG_PATH: /tmp/deps/${{ matrix.target }}/lib/pkgconfig/ + - name: Build image + run: | + docker build \ + --build-arg TARGET=${{ matrix.target }} \ + --build-arg GOARCH=${{ matrix.goarch }} \ + --build-arg CC=${{ matrix.cc }} \ + -t go-librespot-build-${{ matrix.target }} \ + -f Dockerfile.build \ + . + + - name: Compile binary run: | - mkdir -p /tmp/out/${{ matrix.target }}/ - go build \ - -ldflags="-s -w -X go-librespot.commit=${{ github.sha }} -X go-librespot.version=${{ github.ref_name }}" \ - -o ./go-librespot -a ./cmd/daemon + docker run --rm \ + --env COMMIT=${{ github.sha }} \ + --env VERSION=${{ github.ref_name }} \ + -v $PWD:/src \ + go-librespot-build-${{ matrix.target }} tar -zcvf /tmp/out/go-librespot_${{ matrix.tar }}.tar.gz go-librespot README.md - name: Upload compiled binary