|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +env: |
| 10 | + REGISTRY: ghcr.io |
| 11 | + IMAGE_NAME: ${{ github.repository }} |
| 12 | + |
| 13 | +jobs: |
| 14 | + build-client: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + targets: |
| 19 | + - OS: darwin |
| 20 | + ARCH: amd64 |
| 21 | + EXT: "" |
| 22 | + - OS: darwin |
| 23 | + ARCH: arm64 |
| 24 | + EXT: "" |
| 25 | + - OS: windows |
| 26 | + ARCH: amd64 |
| 27 | + EXT: .exe |
| 28 | + - OS: windows |
| 29 | + ARCH: arm64 |
| 30 | + EXT: .exe |
| 31 | + - OS: linux |
| 32 | + ARCH: amd64 |
| 33 | + EXT: "" |
| 34 | + - OS: linux |
| 35 | + ARCH: arm64 |
| 36 | + EXT: "" |
| 37 | + |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + |
| 41 | + - name: Set up Go |
| 42 | + uses: actions/setup-go@v5 |
| 43 | + with: |
| 44 | + go-version: 1.23 |
| 45 | + |
| 46 | + - name: Go Build |
| 47 | + run: | |
| 48 | + export CGO_ENABLED=0 |
| 49 | + export GOOS=${{ matrix.targets.OS }} |
| 50 | + export GOARCH=${{ matrix.targets.ARCH }} |
| 51 | + mkdir -p dist |
| 52 | + go build \ |
| 53 | + -trimpath \ |
| 54 | + -ldflags="-s -w" \ |
| 55 | + -o dist/wst-${{ matrix.targets.OS }}-${{ matrix.targets.ARCH }}${{ matrix.targets.EXT }} \ |
| 56 | + ./client |
| 57 | +
|
| 58 | + - name: Release |
| 59 | + uses: softprops/action-gh-release@v2 |
| 60 | + with: |
| 61 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + draft: false |
| 63 | + prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 64 | + append_body: false |
| 65 | + fail_on_unmatched_files: true |
| 66 | + name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'Dev Build' }} |
| 67 | + tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'dev' }} |
| 68 | + files: | |
| 69 | + dist/* |
| 70 | +
|
| 71 | + build-server: |
| 72 | + runs-on: ubuntu-latest |
| 73 | + |
| 74 | + steps: |
| 75 | + - uses: actions/checkout@v4 |
| 76 | + |
| 77 | + - name: Set up QEMU |
| 78 | + uses: docker/setup-qemu-action@v3 |
| 79 | + |
| 80 | + - name: Set up Docker Buildx |
| 81 | + uses: docker/setup-buildx-action@v3 |
| 82 | + |
| 83 | + - name: Log in to the Container registry |
| 84 | + uses: docker/login-action@v1 |
| 85 | + with: |
| 86 | + registry: ${{ env.REGISTRY }} |
| 87 | + username: ${{ github.actor }} |
| 88 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + |
| 90 | + - name: Extract metadata (tags, labels) for Docker |
| 91 | + id: meta |
| 92 | + uses: docker/metadata-action@v3 |
| 93 | + with: |
| 94 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 95 | + |
| 96 | + - name: Build and push |
| 97 | + id: docker_build |
| 98 | + uses: docker/build-push-action@v5 |
| 99 | + with: |
| 100 | + context: server |
| 101 | + push: true |
| 102 | + platforms: linux/amd64,linux/arm64 |
| 103 | + tags: ${{ steps.meta.outputs.tags }} |
| 104 | + labels: ${{ steps.meta.outputs.labels }} |
| 105 | + |
| 106 | + - name: Image digest |
| 107 | + run: echo ${{ steps.docker_build.outputs.digest }} |
0 commit comments