|
| 1 | +name: Build Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + workflow_call: |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + name: "Build ${{ matrix.goos }} ${{ matrix.goarch }}" |
| 10 | + runs-on: namespace-profile-ubuntu-small |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + include: |
| 14 | + - goos: linux |
| 15 | + goarch: amd64 |
| 16 | + - goos: linux |
| 17 | + goarch: arm64 |
| 18 | + - goos: darwin |
| 19 | + goarch: amd64 |
| 20 | + - goos: darwin |
| 21 | + goarch: arm64 |
| 22 | + - goos: windows |
| 23 | + goarch: amd64 |
| 24 | + - goos: windows |
| 25 | + goarch: arm64 |
| 26 | + steps: |
| 27 | + - name: Check out repository |
| 28 | + uses: actions/checkout@v6 |
| 29 | + |
| 30 | + - name: Install Go |
| 31 | + uses: actions/setup-go@v6 |
| 32 | + with: |
| 33 | + go-version-file: 'go.mod' |
| 34 | + # Use the Namespace Go cache |
| 35 | + cache: false |
| 36 | + |
| 37 | + - name: Set up build cache |
| 38 | + uses: namespacelabs/nscloud-cache-action@v1 |
| 39 | + with: |
| 40 | + cache: go |
| 41 | + |
| 42 | + - name: Build |
| 43 | + env: |
| 44 | + CGO_ENABLED: '0' |
| 45 | + GOOS: ${{ matrix.goos }} |
| 46 | + GOARCH: ${{ matrix.goarch }} |
| 47 | + run: | |
| 48 | + binary="oz-agent-worker" |
| 49 | + if [ "$GOOS" = "windows" ]; then |
| 50 | + binary="oz-agent-worker.exe" |
| 51 | + fi |
| 52 | + go build -o "$binary" . |
| 53 | +
|
| 54 | + - name: Archive |
| 55 | + run: | |
| 56 | + prefix="oz-agent-worker-${{ matrix.goos }}-${{ matrix.goarch }}" |
| 57 | + if [ "${{ matrix.goos }}" = "windows" ]; then |
| 58 | + zip "${prefix}.zip" oz-agent-worker.exe |
| 59 | + else |
| 60 | + tar czf "${prefix}.tar.gz" oz-agent-worker |
| 61 | + tar cJf "${prefix}.tar.xz" oz-agent-worker |
| 62 | + fi |
| 63 | +
|
| 64 | + - name: Upload artifact |
| 65 | + uses: namespace-actions/upload-artifact@v1 |
| 66 | + with: |
| 67 | + name: oz-agent-worker-${{ matrix.goos }}-${{ matrix.goarch }} |
| 68 | + path: | |
| 69 | + oz-agent-worker-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz |
| 70 | + oz-agent-worker-${{ matrix.goos }}-${{ matrix.goarch }}.tar.xz |
| 71 | + oz-agent-worker-${{ matrix.goos }}-${{ matrix.goarch }}.zip |
0 commit comments