.github/workflows/build.yml7.9 KB · YAML
Raw
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: Build hUGETracker

on:
  - push
  - pull_request

jobs:
  build:
    strategy:
      matrix:
        os:
          - ubuntu-24.04
          - macos-14
          - windows-2025
        include:
          - os: ubuntu-24.04
            name: Linux
          - os: macos-14
            name: Mac
          - os: windows-2025
            name: Windows
      fail-fast: false
    runs-on: ${{ matrix.os }}
    steps:
      - name: Check out hUGETracker
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          path: hUGETracker
          submodules: true # This is intentionally not "recursive", change if needed

      - name: Install Ubuntu dependencies
        if: matrix.name == 'Linux'
        run: |
          sudo apt -qq update
          sudo apt install -yq libsdl2-dev bison libasound2-dev
          curl -Lo rgbds.tar.gz 'https://github.com/gbdev/rgbds/releases/download/v0.8.0/rgbds-0.8.0.tar.gz'
          tar xvf rgbds.tar.gz rgbds/{include,src,Makefile}
          cd rgbds
          make -j4 rgbasm rgblink rgbfix Q=

          wget https://netactuate.dl.sourceforge.net/project/lazarus/Lazarus%20Linux%20amd64%20DEB/Lazarus%203.0/lazarus-project_3.0.0-0_amd64.deb
          wget https://cytranet.dl.sourceforge.net/project/lazarus/Lazarus%20Linux%20amd64%20DEB/Lazarus%203.0/fpc-laz_3.2.2-210709_amd64.deb
          wget https://versaweb.dl.sourceforge.net/project/lazarus/Lazarus%20Linux%20amd64%20DEB/Lazarus%203.0/fpc-src_3.2.2-210709_amd64.deb

          sudo apt install -yq ./fpc-laz_3.2.2-210709_amd64.deb ./fpc-src_3.2.2-210709_amd64.deb ./lazarus-project_3.0.0-0_amd64.deb

          # FFmpeg dependencies
          sudo apt-get -y install autoconf automake cmake libtool meson ninja-build pkg-config yasm zlib1g-dev

      - name: Build PortMidi (Linux)
        if: matrix.name == 'Linux'
        shell: bash
        run: ./hUGETracker/.github/scripts/build-portmidi.sh

      - name: Install macOS dependencies
        if: matrix.name == 'Mac'
        run: |
          brew install --cask lazarus
          brew install ./hUGETracker/.github/brew/rgbds.rb
          brew install automake libtool shtool wget yasm

          curl -Lo 'sdl2.tgz' https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.28.5.tar.gz
          tar xzf sdl2.tgz
          pushd SDL-release-2.28.5
          ./configure --disable-video --disable-render --disable-haptic --disable-joystick \
                      --disable-power --disable-hidapi --disable-sensor --disable-filesystem \
                      --disable-timers --disable-atomic --disable-file --disable-misc \
                      --disable-locale --disable-loadso --disable-cpuinfo
          make -j$(sysctl -n hw.ncpu)
          sudo cp build/.libs/libSDL2.a /usr/local/lib
          popd

          mkdir rgbds
          for f in asm link fix; do ln -s `which rgb$f` rgbds/rgb$f; done

      - name: Build PortMidi (Mac)
        if: matrix.name == 'Mac'
        shell: bash
        run: ./hUGETracker/.github/scripts/build-portmidi.sh

      - name: Install Windows dependencies
        if: matrix.name == 'Windows'
        shell: bash
        run: |
          choco install lazarus zip
          curl -Lo 'sdl2.zip' 'https://github.com/libsdl-org/SDL/releases/download/release-2.28.5/SDL2-2.28.5-win32-x64.zip'
          curl -Lo 'rgbds.zip' 'https://github.com/gbdev/rgbds/releases/download/v0.8.0/rgbds-0.8.0-win64.zip'
          unzip -d rgbds rgbds.zip rgb{asm,link,fix}.exe

      - name: Set up MSYS2
        if: matrix.name == 'Windows'
        uses: msys2/setup-msys2@v2
        with:
          msystem: MINGW64
          path-type: strict
          release: false
          update: false
          install: >-
            base-devel
            mingw-w64-x86_64-toolchain
            yasm

      - name: Build PortMidi (Windows)
        if: matrix.name == 'Windows'
        shell: msys2 {0}
        run: ./hUGETracker/.github/scripts/build-portmidi.sh

      - name: Compile FFmpeg (Windows)
        if: matrix.name == 'Windows'
        shell: msys2 {0}
        run: ./hUGETracker/.github/scripts/build-ffmpeg.sh

      - name: Compile FFmpeg (Mac and Linux)
        if: matrix.name == 'Mac' || matrix.name == 'Linux'
        shell: bash
        run: ./hUGETracker/.github/scripts/build-ffmpeg.sh

      - name: Build release
        shell: bash
        working-directory: hUGETracker
        run: | # The PATH manipulation is because the macOS and Windows installs do NOT put it in the PATH >_<
          export PATH="$PATH":/Applications/Lazarus:/c/lazarus
          export VERSION_STRING=`git describe --tags --dirty --always`

          lazbuild --add-package-link src/rackctls/RackCtlsPkg.lpk
          lazbuild --add-package-link src/bgrabitmap/bgrabitmap/bgrabitmappack.lpk

          lazbuild src/hUGETracker.lpi --build-mode="Production ${{ matrix.name }}"
          lazbuild src/uge2source/uge2source.lpi --build-mode=Release

      - name: Package build
        shell: bash
        run: | # macOS does NOT have `realpath` :)
          mkdir packaging
          for f in hUGETracker/{sample-songs,src/hUGEDriver,fonts/PixeliteTTF.ttf,keymaps}; do ln -sv "$PWD/$f" packaging; done
          OBJ=`mktemp`
          HDOBJ=`mktemp`
          rgbds/rgbasm -E -i hUGETracker/src/hUGEDriver -o "$HDOBJ" hUGETracker/src/hUGEDriver/hUGEDriver.asm
          rgbds/rgbasm -i hUGETracker/src/hUGEDriver/include -o "$OBJ" hUGETracker/src/halt.asm
          rgbds/rgblink -o packaging/halt.gb -n packaging/halt.sym "$OBJ" "$HDOBJ"
          rgbds/rgbfix -vp0xFF packaging/halt.gb
          rm "$OBJ" "$HDOBJ"
          cp -v hUGETracker/src/Release/hUGETracker hUGETracker/src/uge2source/Release/uge2source packaging

          mv packaging/sample-songs "packaging/Sample Songs"
          mv packaging/keymaps "packaging/Keymaps"

      - name: Extra Windows packaging
        if: matrix.name == 'Windows'
        shell: bash
        run: |
          unzip -d packaging sdl2.zip SDL2.dll
          cp -v ffmpeg-4.4/ffmpeg.exe rgbds/* packaging
          cp -v portmidi-install/bin/libportmidi.dll packaging/portmidi.dll

      - name: Extra Mac packaging
        if: matrix.name == 'Mac'
        shell: bash
        run: |
          cp -Rpv hUGETracker/src/Release/hUGETracker.app packaging
          cp -v hUGETracker/graphics/hUGETracker.icns packaging/hUGETracker.app/Contents/Resources
          mv packaging/{halt.gb,halt.sym,hUGEDriver,PixeliteTTF.ttf} packaging/hUGETracker.app/Contents/Resources
          for f in asm link fix; do ln -s `which rgb$f` packaging/hUGETracker.app/Contents/MacOS/rgb$f; done
          cp -v ffmpeg-4.4/ffmpeg packaging/hUGETracker.app/Contents/MacOS
          if [ -f portmidi-install/lib/libportmidi.dylib ]; then
            cp -Rv portmidi-install/lib/libportmidi*.dylib packaging/hUGETracker.app/Contents/MacOS/
          fi

          # Hacky, but unlikely to break any time soon.
          ed packaging/hUGETracker.app/Contents/Info.plist << END
          5i
          <key>CFBundleIconFile</key>
          <string>hUGETracker.icns</string>
          .
          w
          q
          END

      - name: Extra Linux packaging
        if: matrix.name == 'Linux'
        shell: bash
        run: |
          for f in asm link fix; do cp -v rgbds/rgb$f packaging/rgb$f; done
          cp -v ffmpeg-4.4/ffmpeg packaging
          # Bundle portmidi so users don't need libportmidi-dev installed.
          # We ship both versioned and unversioned names so dlopen finds it.
          cp -Pv portmidi-install/lib/libportmidi.so* packaging/

      - name: Zip files (preserving permissions)
        shell: bash
        run: |
          shopt -s extglob
          pushd packaging
          if [ "${{ matrix.name }}" == "Mac" ]; then
            zip -r ../build.zip !(hUGETracker)
          else
            zip -r ../build.zip *
          fi
          popd

      - name: Store build
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.name }} build
          path: build.zip