|
8 | 8 | env:
|
9 | 9 | REGISTRY: ghcr.io
|
10 | 10 | IMAGE_NAME: ${{ github.repository }}
|
11 |
| - BUILDX_VERSIONS: linux/amd64 |
| 11 | + BUILDX_VERSIONS: linux/amd64,linux/arm64,linux/arm/v7 |
| 12 | + GO_VERSION: 1.17 |
12 | 13 |
|
13 | 14 | jobs:
|
14 |
| - build-and-push-image: |
| 15 | + build-go: |
15 | 16 | runs-on: ubuntu-latest
|
16 | 17 | permissions:
|
17 | 18 | contents: read
|
18 |
| - packages: write |
19 |
| - |
20 | 19 | steps:
|
21 | 20 | - name: Checkout repository
|
22 | 21 | uses: actions/checkout@v2
|
23 | 22 | with:
|
24 | 23 | fetch-depth: 2
|
25 | 24 |
|
| 25 | + - name: Setup go |
| 26 | + id: go |
| 27 | + uses: actions/setup-go@v2 |
| 28 | + with: |
| 29 | + go-version: ${{ env.GO_VERSION }} |
| 30 | + |
| 31 | + - name: Cache go |
| 32 | + uses: actions/cache@v2.1.6 |
| 33 | + with: |
| 34 | + path: | |
| 35 | + ~/.cache/go-build |
| 36 | + ~/go/pkg/mod |
| 37 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 38 | + restore-keys: | |
| 39 | + ${{ runner.os }}-go- |
| 40 | +
|
| 41 | + - name: Cache app build |
| 42 | + id: app_cache |
| 43 | + uses: actions/cache@v2.1.6 |
| 44 | + with: |
| 45 | + path: ./bin/ |
| 46 | + key: ${{ runner.os }}-webapp-${{ hashFiles('bin') }} |
| 47 | + |
| 48 | + - name: Build go binaries |
| 49 | + run: | |
| 50 | + export CGO_ENABLED=0 |
| 51 | + for TARGETPLATFORM in $( echo ${{ env.BUILDX_VERSIONS }} | tr -s ',' ' ' ); do |
| 52 | + time go build -ldflags="-d -s -w" -o ./bin/${TARGETPLATFORM}/postmanq -a cmd/postmanq/main.go & |
| 53 | + time go build -ldflags="-d -s -w" -o ./bin/${TARGETPLATFORM}/pmq-grep -a cmd/tools/pmq-grep/main.go & |
| 54 | + time go build -ldflags="-d -s -w" -o ./bin/${TARGETPLATFORM}/pmq-publish -a cmd/tools/pmq-publish/main.go & |
| 55 | + time go build -ldflags="-d -s -w" -o ./bin/${TARGETPLATFORM}/pmq-report -a cmd/tools/pmq-report/main.go & |
| 56 | + time go build -ldflags="-d -s -w" -o ./bin/${TARGETPLATFORM}/healthcheck -a cmd/healthcheck/main.go & |
| 57 | + done |
| 58 | + wait |
| 59 | +
|
| 60 | + - uses: actions/upload-artifact@v2 |
| 61 | + with: |
| 62 | + name: application |
| 63 | + path: | |
| 64 | + ./bin/ |
| 65 | + ./build/ |
| 66 | + ./config.yaml |
| 67 | +
|
| 68 | + build-and-publish-image: |
| 69 | + needs: build-go |
| 70 | + runs-on: ubuntu-latest |
| 71 | + strategy: |
| 72 | + matrix: |
| 73 | + include: |
| 74 | + - docker: postman |
| 75 | + tagSuffix: "" |
| 76 | + - docker: postman/alpine |
| 77 | + tagSuffix: "-alpine" |
| 78 | + permissions: |
| 79 | + packages: write |
| 80 | + steps: |
| 81 | + - uses: actions/download-artifact@v2 |
| 82 | + with: |
| 83 | + name: application |
| 84 | + |
26 | 85 | - name: Set up QEMU
|
27 | 86 | uses: docker/setup-qemu-action@v1
|
28 | 87 |
|
|
45 | 104 | type=ref,event=branch
|
46 | 105 | type=ref,event=pr
|
47 | 106 | type=semver,pattern={{major}}.{{minor}}.{{patch}}
|
| 107 | + flavor: | |
| 108 | + suffix=${{ matrix.tagSuffix }},onlatest=true |
48 | 109 |
|
49 | 110 | - name: Cache Docker layers
|
50 | 111 | uses: actions/cache@v2.1.6
|
|
59 | 120 | id: docker_build
|
60 | 121 | uses: docker/build-push-action@v2
|
61 | 122 | with:
|
| 123 | + file: build/${{ matrix.docker }}/Dockerfile |
62 | 124 | context: .
|
63 | 125 | cache-from: type=local,src=/tmp/.buildx-cache
|
64 | 126 | cache-to: type=local,dest=/tmp/.buildx-cache-new
|
|
0 commit comments