|
| 1 | +name: Docker GHCR Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v[0-9]+.[0-9]+.[0-9]*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + packages: write |
| 10 | + contents: read |
| 11 | + |
| 12 | +env: |
| 13 | + REGISTRY: ghcr.io |
| 14 | + IMAGE_NAME: disentangle-network/nebula-pq |
| 15 | + |
| 16 | +jobs: |
| 17 | + build-binaries: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - goos: linux |
| 23 | + goarch: amd64 |
| 24 | + - goos: linux |
| 25 | + goarch: arm64 |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + - uses: actions/setup-go@v5 |
| 29 | + with: |
| 30 | + go-version: '1.23' |
| 31 | + - name: Build |
| 32 | + env: |
| 33 | + GOOS: ${{ matrix.goos }} |
| 34 | + GOARCH: ${{ matrix.goarch }} |
| 35 | + run: | |
| 36 | + make BUILD_NUMBER="${GITHUB_REF#refs/tags/v}" \ |
| 37 | + build/${{ matrix.goos }}-${{ matrix.goarch }}/nebula \ |
| 38 | + build/${{ matrix.goos }}-${{ matrix.goarch }}/nebula-cert |
| 39 | + - name: Upload artifacts |
| 40 | + uses: actions/upload-artifact@v4 |
| 41 | + with: |
| 42 | + name: build-${{ matrix.goos }}-${{ matrix.goarch }} |
| 43 | + path: build/${{ matrix.goos }}-${{ matrix.goarch }}/ |
| 44 | + |
| 45 | + push-image: |
| 46 | + needs: build-binaries |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - name: Download amd64 artifacts |
| 52 | + uses: actions/download-artifact@v4 |
| 53 | + with: |
| 54 | + name: build-linux-amd64 |
| 55 | + path: build/linux-amd64/ |
| 56 | + |
| 57 | + - name: Download arm64 artifacts |
| 58 | + uses: actions/download-artifact@v4 |
| 59 | + with: |
| 60 | + name: build-linux-arm64 |
| 61 | + path: build/linux-arm64/ |
| 62 | + |
| 63 | + - name: Set up QEMU |
| 64 | + uses: docker/setup-qemu-action@v3 |
| 65 | + |
| 66 | + - name: Set up Docker Buildx |
| 67 | + uses: docker/setup-buildx-action@v3 |
| 68 | + |
| 69 | + - name: Login to GHCR |
| 70 | + uses: docker/login-action@v3 |
| 71 | + with: |
| 72 | + registry: ${{ env.REGISTRY }} |
| 73 | + username: ${{ github.actor }} |
| 74 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + |
| 76 | + - name: Extract version |
| 77 | + id: version |
| 78 | + run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT |
| 79 | + |
| 80 | + - name: Build and push multi-arch |
| 81 | + uses: docker/build-push-action@v6 |
| 82 | + with: |
| 83 | + context: . |
| 84 | + file: docker/Dockerfile |
| 85 | + push: true |
| 86 | + platforms: linux/amd64,linux/arm64 |
| 87 | + tags: | |
| 88 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }} |
| 89 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest |
0 commit comments