|
| 1 | +name: Release |
| 2 | +on: push |
| 3 | +env: |
| 4 | + APP: iv |
| 5 | + VER: ${{ github.ref_name }} |
| 6 | + GO_VERSION: stable |
| 7 | + |
| 8 | +jobs: |
| 9 | + build_for_linux: |
| 10 | + name: Build for Linux |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + arch: [amd64, arm, arm64] |
| 16 | + steps: |
| 17 | + - name: Install build dependencies |
| 18 | + run: | |
| 19 | + sudo apt-get -qq update |
| 20 | + sudo apt-get install -y \ |
| 21 | + build-essential \ |
| 22 | + qemu-user \ |
| 23 | + gcc-arm-linux-gnueabihf \ |
| 24 | + g++-arm-linux-gnueabihf \ |
| 25 | + gcc-aarch64-linux-gnu \ |
| 26 | + g++-aarch64-linux-gnu \ |
| 27 | + libstdc++6-armhf-cross \ |
| 28 | + libstdc++6-arm64-cross \ |
| 29 | + libc6-dev-armhf-cross \ |
| 30 | + libc6-dev-arm64-cross \ |
| 31 | + file |
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v4 |
| 34 | + - name: Setup Go |
| 35 | + uses: actions/setup-go@v4 |
| 36 | + with: |
| 37 | + go-version: ${{ env.GO_VERSION }} |
| 38 | + - name: Build ${{ matrix.arch }} |
| 39 | + run: | |
| 40 | + ./build.sh -v $VER -a ${{ matrix.arch }} |
| 41 | + - name: Build ${{ matrix.arch }} (static) |
| 42 | + if: matrix.arch != 'arm' |
| 43 | + run: | |
| 44 | + ./build.sh -v $VER -a ${{ matrix.arch }} -s |
| 45 | + - name: Archive artifacts |
| 46 | + uses: actions/upload-artifact@v3 |
| 47 | + with: |
| 48 | + name: dist-linux-${{ matrix.arch }} |
| 49 | + path: build/linux/**/* |
| 50 | + if-no-files-found: error |
| 51 | + |
| 52 | + build_for_macos: |
| 53 | + name: Build for macOS |
| 54 | + runs-on: macos-latest |
| 55 | + strategy: |
| 56 | + matrix: |
| 57 | + arch: [amd64, arm64] |
| 58 | + steps: |
| 59 | + - name: Install build dependencies |
| 60 | + run: | |
| 61 | + brew install coreutils gnu-tar |
| 62 | + - name: Checkout |
| 63 | + uses: actions/checkout@v4 |
| 64 | + - name: Setup Go |
| 65 | + uses: actions/setup-go@v4 |
| 66 | + with: |
| 67 | + go-version: ${{ env.GO_VERSION }} |
| 68 | + - name: Build ${{ matrix.arch }} |
| 69 | + run: | |
| 70 | + ./build.sh -v $VER -a ${{ matrix.arch }} |
| 71 | + - name: Archive artifacts |
| 72 | + uses: actions/upload-artifact@v3 |
| 73 | + with: |
| 74 | + name: dist-darwin-${{ matrix.arch }} |
| 75 | + path: build/darwin/**/* |
| 76 | + if-no-files-found: error |
| 77 | + |
| 78 | + build_for_macos_universal: |
| 79 | + name: Build for macOS (universal) |
| 80 | + needs: |
| 81 | + - build_for_macos |
| 82 | + runs-on: macos-latest |
| 83 | + steps: |
| 84 | + - name: Install build dependencies |
| 85 | + run: | |
| 86 | + brew install coreutils gnu-tar |
| 87 | + - name: Download artifacts |
| 88 | + uses: actions/download-artifact@v3 |
| 89 | + - name: Build universal |
| 90 | + run: | |
| 91 | + export WORKDIR=$PWD/build/darwin/universal/$VER |
| 92 | + mkdir -p $WORKDIR |
| 93 | +
|
| 94 | + gtar -jxvf dist-darwin-amd64/*/*/*.tar.bz2 -C $WORKDIR $APP |
| 95 | + gtar -jxvf dist-darwin-amd64/*/*/*.tar.bz2 -C $WORKDIR LICENSE |
| 96 | + mv $WORKDIR/$APP $WORKDIR/$APP-amd64 |
| 97 | +
|
| 98 | + gtar -jxvf dist-darwin-arm64/*/*/*.tar.bz2 -C $WORKDIR $APP |
| 99 | + mv $WORKDIR/$APP $WORKDIR/$APP-arm64 |
| 100 | +
|
| 101 | + file $WORKDIR/$APP-{amd64,arm64} |
| 102 | +
|
| 103 | + lipo -create -output $WORKDIR/$APP $WORKDIR/$APP-amd64 $WORKDIR/$APP-arm64 |
| 104 | + chmod +x $WORKDIR/$APP |
| 105 | + file $WORKDIR/$APP |
| 106 | +
|
| 107 | + rm $WORKDIR/$APP-{amd64,arm64} |
| 108 | +
|
| 109 | + sudo /usr/sbin/purge |
| 110 | +
|
| 111 | + gtar -C $WORKDIR -cjf $WORKDIR/$APP-${VER#v}-darwin-universal.tar.bz2 $APP LICENSE |
| 112 | + ls -alh $WORKDIR/* |
| 113 | + sha256sum $WORKDIR/* |
| 114 | + - name: Archive artifacts |
| 115 | + uses: actions/upload-artifact@v3 |
| 116 | + with: |
| 117 | + name: dist-darwin-universal |
| 118 | + path: build/darwin/**/* |
| 119 | + if-no-files-found: error |
| 120 | + |
| 121 | + build_for_windows: |
| 122 | + name: Build for Windows |
| 123 | + runs-on: windows-latest |
| 124 | + steps: |
| 125 | + - name: Install build dependencies |
| 126 | + run: choco install zip |
| 127 | + - name: Checkout |
| 128 | + uses: actions/checkout@v4 |
| 129 | + - name: Setup Go |
| 130 | + uses: actions/setup-go@v4 |
| 131 | + with: |
| 132 | + go-version: ${{ env.GO_VERSION }} |
| 133 | + - name: Build amd64 |
| 134 | + shell: bash |
| 135 | + run: | |
| 136 | + ./build.sh -v $VER |
| 137 | + - name: Archive artifacts |
| 138 | + uses: actions/upload-artifact@v3 |
| 139 | + with: |
| 140 | + name: dist-windows |
| 141 | + path: build/windows/**/* |
| 142 | + if-no-files-found: error |
| 143 | + |
| 144 | + release: |
| 145 | + name: Draft Release |
| 146 | + needs: |
| 147 | + - build_for_linux |
| 148 | + - build_for_macos |
| 149 | + - build_for_macos_universal |
| 150 | + - build_for_windows |
| 151 | + runs-on: ubuntu-latest |
| 152 | + steps: |
| 153 | + - name: Download artifacts |
| 154 | + uses: actions/download-artifact@v3 |
| 155 | + - name: Release |
| 156 | + uses: softprops/action-gh-release@v1 |
| 157 | + if: startsWith(github.ref, 'refs/tags/v') |
| 158 | + with: |
| 159 | + name: ${{ env.APP }} ${{ env.VER }} |
| 160 | + draft: true |
| 161 | + generate_release_notes: true |
| 162 | + files: | |
| 163 | + dist-*/*/*/*.tar.bz2 |
| 164 | + dist-*/*/*/*.zip |
0 commit comments