http.yml raw

   1  name: HTTP build - Linux and MacOS
   2  on:
   3    push:
   4      branches:
   5        - master
   6    pull_request:
   7      types: [opened, synchronize]
   8    workflow_call:
   9      inputs:
  10        build-release:
  11          description: "Build full-featured http release (codesigning, notarization, etc.)"
  12          type: boolean
  13      secrets:
  14        APPLE_DEVELOPER_CERTIFICATE_P12_BASE64:
  15          required: true
  16        APPLE_DEVELOPER_CERTIFICATE_PASSWORD:
  17          required: true
  18        APPLE_PASSWORD:
  19          required: true
  20        APPLE_TEAM_ID:
  21          required: true
  22        APPLE_USERNAME:
  23          required: true
  24  
  25  jobs:
  26    build:
  27      strategy:
  28        fail-fast: false
  29        matrix:
  30          build:
  31            [
  32              {
  33                arch: x86_64,
  34                alby_arch: x86_64-unknown-linux-gnu,
  35                os: ubuntu-22.04,
  36              },
  37              {
  38                arch: armv6,
  39                alby_arch: arm-unknown-linux-gnueabihf,
  40                os: ubuntu-22.04,
  41              },
  42              {
  43                arch: aarch64,
  44                alby_arch: aarch64-unknown-linux-gnu,
  45                os: ubuntu-22.04,
  46              },
  47              { arch: darwin/universal, os: macos-14 },
  48            ]
  49      runs-on: ${{ matrix.build.os }}
  50  
  51      steps:
  52        - name: Setup
  53          run: |
  54            echo "EXEC_NAME=albyhub" >> $GITHUB_ENV
  55            if [ "${{ runner.os }}" == "macOS" ]; then
  56              echo "PACKAGE_NAME=albyhub-Server-MacOS" >> $GITHUB_ENV
  57            else
  58              echo "PACKAGE_NAME=albyhub-Server-Linux-${{ matrix.build.arch }}" >> $GITHUB_ENV
  59            fi
  60  
  61        - uses: actions/checkout@v4
  62          name: Check out code
  63          with:
  64            submodules: recursive
  65  
  66        - name: Install Linux dependencies
  67          if: runner.os == 'Linux'
  68          run: |
  69            sudo apt-get update
  70            sudo apt-get install -y patchelf gcc
  71  
  72        - name: Install macOS Wails deps
  73          if: runner.os == 'macOS'
  74          run: |
  75            brew install Bearer/tap/gon
  76          shell: bash
  77  
  78        - name: Setup GoLang
  79          uses: actions/setup-go@v5
  80          with:
  81            go-version-file: "./go.mod"
  82  
  83        - name: Get dependencies
  84          run: go get -v -t -d ./...
  85  
  86        - name: Setup NodeJS
  87          uses: actions/setup-node@v4
  88          with:
  89            node-version: "22.x"
  90  
  91        - name: Run tests
  92          run: mkdir frontend/dist && touch frontend/dist/tmp && go test ./...
  93  
  94        - name: Build frontend
  95          run: |
  96            cd frontend
  97            yarn install
  98            yarn build:http
  99          shell: bash
 100  
 101        - name: Create build directory
 102          run: |
 103            mkdir -p ./build/bin/${{ env.PACKAGE_NAME }}/lib
 104  
 105        - name: Install ARM6 cross-compiler
 106          if: matrix.build.arch == 'armv6'
 107          run: |
 108            wget -nv https://github.com/getAlby/gcc-arm-linux-gnueabihf/releases/download/v1.0.0/armv6-unknown-linux-gnueabihf.tar.bz2
 109            tar -xf armv6-unknown-linux-gnueabihf.tar.bz2
 110            echo "GOOS=linux" >> $GITHUB_ENV
 111            echo "GOARCH=arm" >> $GITHUB_ENV
 112            echo "GOARM=6" >> $GITHUB_ENV
 113            echo "CC=$GITHUB_WORKSPACE/armv6-unknown-linux-gnueabihf/bin/armv6-unknown-linux-gnueabihf-gcc" >> $GITHUB_ENV
 114            echo "GOTAGS=-tags netgo" >> $GITHUB_ENV
 115  
 116        - name: Install ARM64 cross-compiler
 117          if: matrix.build.arch == 'aarch64'
 118          run: |
 119            sudo apt-get install -y gcc-aarch64-linux-gnu
 120            echo "GOOS=linux" >> $GITHUB_ENV
 121            echo "GOARCH=arm64" >> $GITHUB_ENV
 122            echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
 123            echo "GOTAGS=-tags netgo" >> $GITHUB_ENV
 124  
 125        - name: Build Binary for Linux and MacOS
 126          env:
 127            CGO_ENABLED: 1
 128            TAG: ${{ github.ref_name }}
 129          run: go build ${{ env.GOTAGS }} -o build/bin/${{ env.PACKAGE_NAME }}/bin/${{ env.EXEC_NAME }} -ldflags "-X 'github.com/getAlby/hub/version.Tag=${{ env.TAG }}'" cmd/http/main.go
 130  
 131        - name: Import Code-Signing Certificates for macOS
 132          if: >-
 133            runner.os == 'macOS' &&
 134            (
 135              !github.event.pull_request ||
 136              (
 137                github.event.pull_request.head.repo.full_name == github.repository &&
 138                github.actor != 'dependabot[bot]'
 139              )
 140            )
 141          uses: Apple-Actions/import-codesign-certs@v3
 142          with:
 143            # The certificates in a PKCS12 file encoded as a base64 string
 144            p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
 145            # The password used to import the PKCS12 file.
 146            p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
 147  
 148        - name: Copy shared libraries to the output directory
 149          if: runner.os == 'Linux'
 150          run: |
 151            mkdir -p ./build/bin/${{ env.PACKAGE_NAME }}/lib
 152            cp `go list -m -f "{{.Dir}}" github.com/getAlby/ldk-node-go`/ldk_node/${{ matrix.build.alby_arch }}/libldk_node.so ./build/bin/${{ env.PACKAGE_NAME }}/lib/
 153          shell: bash
 154  
 155        - name: Patch executable RPATH
 156          if: runner.os == 'Linux'
 157          run: |
 158            patchelf --force-rpath --set-rpath '$ORIGIN/../lib' ./build/bin/${{ env.PACKAGE_NAME }}/bin/${{ env.EXEC_NAME }}
 159  
 160        - name: Copy shared libraries to the output directory
 161          if: runner.os == 'macOS'
 162          run: |
 163            cp `go list -m -f "{{.Dir}}" github.com/getAlby/ldk-node-go`/ldk_node/universal-macos/libldk_node.dylib ./build/bin/${{ env.PACKAGE_NAME }}/lib/
 164          shell: bash
 165  
 166        - name: Patch executable RPATH
 167          if: runner.os == 'macOS'
 168          run: |
 169            install_name_tool -add_rpath @executable_path/../lib ./build/bin/${{ env.PACKAGE_NAME }}/bin/${{ env.EXEC_NAME }}
 170  
 171        - name: Add permissions
 172          run: |
 173            chmod +x build/bin/${{ env.PACKAGE_NAME }}/bin/${{ env.EXEC_NAME }}
 174          shell: bash
 175  
 176        - name: Sign the MacOS binary and libraries
 177          if: >-
 178            runner.os == 'macOS' &&
 179            (
 180              !github.event.pull_request ||
 181              (
 182                github.event.pull_request.head.repo.full_name == github.repository &&
 183                github.actor != 'dependabot[bot]'
 184              )
 185            )
 186          run: |
 187            /usr/bin/codesign -s "Developer ID Application: Alby Inc." -f -v --deep --timestamp --options runtime ./build/bin/${{ env.PACKAGE_NAME }}/bin/${{ env.EXEC_NAME }}
 188            /usr/bin/codesign -s "Developer ID Application: Alby Inc." -f -v --deep --timestamp --options runtime ./build/bin/${{ env.PACKAGE_NAME }}/lib/*.dylib
 189          env:
 190            AC_USERNAME: ${{ secrets.APPLE_USERNAME }}
 191            AC_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
 192            AC_PROVIDER: ${{ secrets.APPLE_TEAM_ID }}
 193  
 194        - name: Make output tar archive to keep file permissions
 195          if: runner.os == 'Linux'
 196          run: |
 197            mkdir -p ./build/out
 198            tar -cjf ./build/out/${{ env.PACKAGE_NAME }}.tar.bz2 -C ./build/bin/${{ env.PACKAGE_NAME }} .
 199  
 200        - name: Make output zip archive to keep file permissions
 201          if: runner.os == 'macOS'
 202          run: |
 203            mkdir -p ./build/out
 204            cd ./build/bin/${{ env.PACKAGE_NAME }}
 205            zip -r ../../out/${{ env.PACKAGE_NAME }} ./*
 206            cd ../../..
 207  
 208        - name: Notarize the zip file
 209          if: >-
 210            runner.os == 'macOS' &&
 211            inputs.build-release &&
 212            (
 213              !github.event.pull_request ||
 214              (
 215                github.event.pull_request.head.repo.full_name == github.repository &&
 216                github.actor != 'dependabot[bot]'
 217              )
 218            )
 219          run: |
 220            echo "Notarizing Zip Files"
 221            gon -log-level=info -log-json ./build/darwin/http/gon-notarize.json
 222          env:
 223            AC_USERNAME: ${{ secrets.APPLE_USERNAME }}
 224            AC_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
 225            AC_PROVIDER: ${{ secrets.APPLE_TEAM_ID }}
 226  
 227        - uses: actions/upload-artifact@v4
 228          if: runner.os == 'Linux'
 229          with:
 230            name: ${{ env.PACKAGE_NAME }}
 231            path: |
 232              ./build/out/${{ env.PACKAGE_NAME }}.tar.bz2
 233            if-no-files-found: error
 234  
 235        - uses: actions/upload-artifact@v4
 236          if: runner.os == 'macOS'
 237          with:
 238            name: ${{ env.PACKAGE_NAME }}
 239            path: |
 240              ./build/out/${{ env.PACKAGE_NAME }}.zip
 241            if-no-files-found: error
 242