Skip to content

Commit

Permalink
ci: use buildx to replace gorelaser to release image (koordinator-sh#919
Browse files Browse the repository at this point in the history
)

Signed-off-by: Jason Liu <jasonliu747@gmail.com>
  • Loading branch information
jasonliu747 authored Jan 11, 2023
1 parent 3a55a9c commit 5f78591
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 172 deletions.
53 changes: 42 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,18 @@ permissions:
packages: write

jobs:
goreleaser:
build-and-push:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [ koordlet, koord-manager, koord-scheduler, koord-descheduler ]
env:
GITHUB_REG: ghcr.io
ALIYUN_BJ_REG: registry.cn-beijing.aliyuncs.com
ALIYUN_HZ_REG: registry.cn-hangzhou.aliyuncs.com
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
- uses: docker/setup-buildx-action@v2
- name: Login to GHCR
uses: docker/login-action@v2
with:
Expand All @@ -45,6 +40,42 @@ jobs:
registry: ${{ env.ALIYUN_HZ_REG }}
username: ${{ secrets.ALIYUN_USERNAME }}
password: ${{ secrets.ALIYUN_PWD }}
- name: Build and push
uses: docker/build-push-action@v3
with:
platforms: linux/amd64
push: true
pull: true
file: docker/${{ matrix.target }}.dockerfile
labels: |
org.opencontainers.image.title=${{ matrix.target }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.created=${{ github.event.repository.updated_at}}
org.opencontainers.image.licenses=Apache-2.0
tags: |
${{ env.GITHUB_REG }}/${{ github.repository_owner }}/${{ matrix.target }}:${{ github.ref_name }}
${{ env.ALIYUN_BJ_REG }}/${{ github.repository_owner }}/${{ matrix.target }}:${{ github.ref_name }}
${{ env.ALIYUN_HZ_REG }}/${{ github.repository_owner }}/${{ matrix.target }}:${{ github.ref_name }}
cache-from: type=gha,scope=build-${{ matrix.target }}
cache-to: type=gha,mode=max,scope=build-${{ matrix.target }}
goreleaser:
runs-on: ubuntu-latest
env:
GITHUB_REG: ghcr.io
ALIYUN_BJ_REG: registry.cn-beijing.aliyuncs.com
ALIYUN_HZ_REG: registry.cn-hangzhou.aliyuncs.com
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
Expand Down
133 changes: 0 additions & 133 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,66 +20,6 @@ builds:
- -X github.com/koordinator-sh/koordinator/pkg/version.buildDate={{ .Date }}
- -X github.com/koordinator-sh/koordinator/pkg/version.gitCommit={{ .Commit }}
- -X github.com/koordinator-sh/koordinator/pkg/version.gitTreeState=clean
- id: koord-manager
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
main: ./cmd/koord-manager
binary: koord-manager
ldflags:
- -s -w
- -X github.com/koordinator-sh/koordinator/pkg/version.version={{ .Version }}
- -X github.com/koordinator-sh/koordinator/pkg/version.buildDate={{ .Date }}
- -X github.com/koordinator-sh/koordinator/pkg/version.gitCommit={{ .Commit }}
- -X github.com/koordinator-sh/koordinator/pkg/version.gitTreeState=clean
- id: koord-scheduler
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
main: ./cmd/koord-scheduler
binary: koord-scheduler
ldflags:
- -s -w
- -X github.com/koordinator-sh/koordinator/pkg/version.version={{ .Version }}
- -X github.com/koordinator-sh/koordinator/pkg/version.buildDate={{ .Date }}
- -X github.com/koordinator-sh/koordinator/pkg/version.gitCommit={{ .Commit }}
- -X github.com/koordinator-sh/koordinator/pkg/version.gitTreeState=clean
- id: koord-descheduler
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
main: ./cmd/koord-descheduler
binary: koord-descheduler
ldflags:
- -s -w
- -X github.com/koordinator-sh/koordinator/pkg/version.version={{ .Version }}
- -X github.com/koordinator-sh/koordinator/pkg/version.buildDate={{ .Date }}
- -X github.com/koordinator-sh/koordinator/pkg/version.gitCommit={{ .Commit }}
- -X github.com/koordinator-sh/koordinator/pkg/version.gitTreeState=clean
- id: koordlet
env:
- CGO_ENABLED=1
goos:
- linux
goarch:
- amd64
main: ./cmd/koordlet
binary: koordlet
ldflags:
- -s -w
- -X github.com/koordinator-sh/koordinator/pkg/version.version={{ .Version }}
- -X github.com/koordinator-sh/koordinator/pkg/version.buildDate={{ .Date }}
- -X github.com/koordinator-sh/koordinator/pkg/version.gitCommit={{ .Commit }}
- -X github.com/koordinator-sh/koordinator/pkg/version.gitTreeState=clean
archives:
- id: koord-runtime-proxy
format: binary
Expand All @@ -101,76 +41,3 @@ changelog:
- '^test:'
- '^chore:'
- '^feat(deps):'
dockers:
- id: koord-manager
image_templates:
- "ghcr.io/{{.ProjectName}}/koord-manager:{{ .Version }}"
- "registry.cn-beijing.aliyuncs.com/{{.ProjectName}}/koord-manager:{{ .Version }}"
- "registry.cn-hangzhou.aliyuncs.com/{{.ProjectName}}/koord-manager:{{ .Version }}"
dockerfile: .goreleaser/koord-manager.dockerfile
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.title=koord-manager"
- "--label=org.opencontainers.image.source={{.Env.GIT_URL}}"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.licenses=Apache-2.0"
ids:
- koord-manager
goos: linux
goarch: amd64
- id: koordlet
image_templates:
- "ghcr.io/{{.ProjectName}}/koordlet:{{ .Version }}"
- "registry.cn-beijing.aliyuncs.com/{{.ProjectName}}/koordlet:{{ .Version }}"
- "registry.cn-hangzhou.aliyuncs.com/{{.ProjectName}}/koordlet:{{ .Version }}"
dockerfile: .goreleaser/koordlet.dockerfile
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.title=koordlet"
- "--label=org.opencontainers.image.source={{.Env.GIT_URL}}"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.licenses=Apache-2.0"
ids:
- koordlet
goos: linux
goarch: amd64
- id: koord-scheduler
image_templates:
- "ghcr.io/{{.ProjectName}}/koord-scheduler:{{ .Version }}"
- "registry.cn-beijing.aliyuncs.com/{{.ProjectName}}/koord-scheduler:{{ .Version }}"
- "registry.cn-hangzhou.aliyuncs.com/{{.ProjectName}}/koord-scheduler:{{ .Version }}"
dockerfile: .goreleaser/koord-scheduler.dockerfile
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.title=koord-scheduler"
- "--label=org.opencontainers.image.source={{.Env.GIT_URL}}"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.licenses=Apache-2.0"
ids:
- koord-scheduler
goos: linux
goarch: amd64
- id: koord-descheduler
image_templates:
- "ghcr.io/{{.ProjectName}}/koord-descheduler:{{ .Version }}"
- "registry.cn-beijing.aliyuncs.com/{{.ProjectName}}/koord-descheduler:{{ .Version }}"
- "registry.cn-hangzhou.aliyuncs.com/{{.ProjectName}}/koord-descheduler:{{ .Version }}"
dockerfile: .goreleaser/koord-descheduler.dockerfile
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.title=koord-descheduler"
- "--label=org.opencontainers.image.source={{.Env.GIT_URL}}"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.licenses=Apache-2.0"
ids:
- koord-descheduler
goos: linux
goarch: amd64
6 changes: 0 additions & 6 deletions .goreleaser/OWNERS

This file was deleted.

4 changes: 0 additions & 4 deletions .goreleaser/koord-descheduler.dockerfile

This file was deleted.

4 changes: 0 additions & 4 deletions .goreleaser/koord-manager.dockerfile

This file was deleted.

4 changes: 0 additions & 4 deletions .goreleaser/koord-scheduler.dockerfile

This file was deleted.

10 changes: 0 additions & 10 deletions .goreleaser/koordlet.dockerfile

This file was deleted.

0 comments on commit 5f78591

Please sign in to comment.