|
| 1 | +name: Build updater |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + paths: |
| 7 | + - updater/** |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-updater-linux: |
| 11 | + name: Build updater for Linux |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 20 | + |
| 21 | + - name: Mark workspace as safe |
| 22 | + run: git config --global --add safe.directory $GITHUB_WORKSPACE |
| 23 | + |
| 24 | + - name: Set up Go |
| 25 | + uses: actions/setup-go@v4 |
| 26 | + with: |
| 27 | + go-version: "1.21.3" |
| 28 | + cache-dependency-path: updater/go.sum |
| 29 | + |
| 30 | + - name: Ensure dependencies |
| 31 | + working-directory: updater |
| 32 | + run: go mod tidy |
| 33 | + |
| 34 | + - name: Make output dir |
| 35 | + run: mkdir -p updater/output |
| 36 | + |
| 37 | + - name: Build (linux/amd64) |
| 38 | + run: | |
| 39 | + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \ |
| 40 | + go build -o updater/output/updater-linux-64 ./updater |
| 41 | +
|
| 42 | + - name: Upload artifact |
| 43 | + uses: actions/upload-artifact@v4 |
| 44 | + with: |
| 45 | + name: updater-linux |
| 46 | + path: updater/output/* |
| 47 | + |
| 48 | + build-updater-windows: |
| 49 | + name: Build updater for Windows |
| 50 | + runs-on: windows-latest |
| 51 | + |
| 52 | + steps: |
| 53 | + - name: Checkout code |
| 54 | + uses: actions/checkout@v4 |
| 55 | + with: |
| 56 | + fetch-depth: 0 |
| 57 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + |
| 59 | + - name: Mark workspace as safe |
| 60 | + shell: pwsh |
| 61 | + run: git config --global --add safe.directory $Env:GITHUB_WORKSPACE |
| 62 | + |
| 63 | + - name: Set up Go |
| 64 | + uses: actions/setup-go@v4 |
| 65 | + with: |
| 66 | + go-version: "1.21.3" |
| 67 | + cache-dependency-path: updater\go.sum |
| 68 | + |
| 69 | + - name: Ensure dependencies |
| 70 | + working-directory: updater |
| 71 | + shell: pwsh |
| 72 | + run: go mod tidy |
| 73 | + |
| 74 | + - name: Make output dir |
| 75 | + shell: pwsh |
| 76 | + run: New-Item -ItemType Directory -Path updater\output -Force |
| 77 | + |
| 78 | + - name: Build (windows/amd64) |
| 79 | + shell: pwsh |
| 80 | + run: | |
| 81 | + $Env:CGO_ENABLED='0' |
| 82 | + go build -o updater\output\updater-windows-64.exe ./updater |
| 83 | +
|
| 84 | + - name: Upload artifact |
| 85 | + uses: actions/upload-artifact@v4 |
| 86 | + with: |
| 87 | + name: updater-windows |
| 88 | + path: updater\output\* |
| 89 | + |
| 90 | + build-updater-mac: |
| 91 | + name: Build updater for macOS |
| 92 | + runs-on: macos-latest |
| 93 | + |
| 94 | + steps: |
| 95 | + - name: Checkout code |
| 96 | + uses: actions/checkout@v4 |
| 97 | + with: |
| 98 | + fetch-depth: 0 |
| 99 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 100 | + |
| 101 | + - name: Mark workspace as safe |
| 102 | + run: git config --global --add safe.directory $GITHUB_WORKSPACE |
| 103 | + |
| 104 | + - name: Set up Go |
| 105 | + uses: actions/setup-go@v4 |
| 106 | + with: |
| 107 | + go-version: "1.21.3" |
| 108 | + cache-dependency-path: updater/go.sum |
| 109 | + |
| 110 | + - name: Ensure dependencies |
| 111 | + working-directory: updater |
| 112 | + run: go mod tidy |
| 113 | + |
| 114 | + - name: Make output dir |
| 115 | + run: mkdir -p updater/output |
| 116 | + |
| 117 | + - name: Build (macOS Intel) |
| 118 | + run: | |
| 119 | + CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 \ |
| 120 | + go build -o updater/output/updater-macos-64 ./updater |
| 121 | +
|
| 122 | + - name: Build (macOS ARM64) |
| 123 | + run: | |
| 124 | + CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 \ |
| 125 | + go build -o updater/output/updater-macos-m1-64 ./updater |
| 126 | +
|
| 127 | + - name: Upload artifact |
| 128 | + uses: actions/upload-artifact@v4 |
| 129 | + with: |
| 130 | + name: updater-macos |
| 131 | + path: updater/output/* |
0 commit comments