diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index dcf2aaa3a..6d3352d14 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -10,12 +10,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: setup go environment - uses: actions/setup-go@v1 + uses: actions/setup-go@v3 with: go-version: '1.18.1' - name: Build CLI - run: make build-linux + run: make build-linux-amd64 - name: Check version run: bin/linux/amd64/oras version diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8bc3c89ec..3683e242f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,12 +9,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: setup go environment - uses: actions/setup-go@v1 + uses: actions/setup-go@v3 with: go-version: '1.18.1' - name: Build CLI - run: make build-linux + run: make build-linux-amd64 - name: Check version run: bin/linux/amd64/oras version diff --git a/.github/workflows/release-ghcr.yml b/.github/workflows/release-ghcr.yml index bae389ca4..2ed5c401e 100644 --- a/.github/workflows/release-ghcr.yml +++ b/.github/workflows/release-ghcr.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: prepare id: prepare run: | @@ -21,18 +21,16 @@ jobs: fi echo ::set-output name=version::${VERSION} echo ::set-output name=ref::ghcr.io/${{ github.repository }}:${VERSION} - - name: docker build - run: | - docker build -t ${{ steps.prepare.outputs.ref }} . - name: docker login - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ghcr.io - username: ${{ secrets.RELEASE_GHCR_USER_NAME }} - password: ${{ secrets.RELEASE_GHCR_USER_TOKEN }} - - name: docker push - run: | - docker push ${{ steps.prepare.outputs.ref }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: docker build + run: | + docker buildx create --use + docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t ${{ steps.prepare.outputs.ref }} --push . - name: clear if: always() run: | diff --git a/.github/workflows/release-github.yml b/.github/workflows/release-github.yml index 60e390204..9a0f7fb54 100644 --- a/.github/workflows/release-github.yml +++ b/.github/workflows/release-github.yml @@ -10,9 +10,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: setup go environment - uses: actions/setup-go@v1 + uses: actions/setup-go@v3 with: go-version: '1.18.1' - name: run goreleaser @@ -21,4 +21,4 @@ jobs: version: latest args: release --rm-dist env: - GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_USER_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 06e583938..2f8c64656 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -13,9 +13,16 @@ builds: goarch: - amd64 - arm64 + - arm + goarm: + - '7' ignore: - goos: windows goarch: arm64 + - goos: windows + goarch: arm + - goos: darwin + goarch: arm ldflags: # one-line ldflags to bypass the goreleaser bugs # the git tree state is guaranteed to be clean by goreleaser @@ -29,6 +36,9 @@ archives: - goos: windows format: zip +release: + draft: true + prerelease: auto #signs: # - artifacts: all # args: ["--output", "${signature}", "--detach-sign", "--armor", "${artifact}"] diff --git a/Dockerfile b/Dockerfile index d67c740c5..5a99c4280 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,13 @@ FROM docker.io/library/golang:1.18.1-alpine as builder +ARG TARGETPLATFORM RUN apk add git make ENV ORASPKG /oras ADD . ${ORASPKG} WORKDIR ${ORASPKG} -RUN make build-linux -RUN mv ${ORASPKG}/bin/linux/amd64/oras /go/bin/oras +RUN make "build-$(echo $TARGETPLATFORM | tr / -)" +RUN mv ${ORASPKG}/bin/${TARGETPLATFORM}/oras /go/bin/oras -FROM docker.io/library/alpine:3.13.5 -LABEL maintainer="shizh@microsoft.com" +FROM docker.io/library/alpine:3.15.4 RUN apk --update add ca-certificates COPY --from=builder /go/bin/oras /bin/oras RUN mkdir /workspace diff --git a/Makefile b/Makefile index f1e663b98..f0f0c1daf 100644 --- a/Makefile +++ b/Makefile @@ -30,10 +30,13 @@ clean: git status --ignored --short | grep '^!! ' | sed 's/!! //' | xargs rm -rf .PHONY: build -build: build-linux build-linux-arm64 build-mac build-mac-arm64 build-windows +build: build-linux build-mac build-windows .PHONY: build-linux -build-linux: +build-linux: build-linux-amd64 build-linux-arm64 build-linux-arm-v7 + +.PHONY: build-linux-amd64 +build-linux-amd64: GOARCH=amd64 CGO_ENABLED=0 GOOS=linux go build -v --ldflags="$(LDFLAGS)" \ -o bin/linux/amd64/$(CLI_EXE) $(CLI_PKG) @@ -42,8 +45,16 @@ build-linux-arm64: GOARCH=arm64 CGO_ENABLED=0 GOOS=linux go build -v --ldflags="$(LDFLAGS)" \ -o bin/linux/arm64/$(CLI_EXE) $(CLI_PKG) +.PHONY: build-linux-arm-v7 +build-linux-arm-v7: + GOARCH=arm CGO_ENABLED=0 GOOS=linux go build -v --ldflags="$(LDFLAGS)" \ + -o bin/linux/arm/v7/$(CLI_EXE) $(CLI_PKG) + .PHONY: build-mac -build-mac: +build-mac: build-mac-arm64 build-mac-amd64 + +.PHONY: build-mac-amd64 +build-mac-amd64: GOARCH=amd64 CGO_ENABLED=0 GOOS=darwin go build -v --ldflags="$(LDFLAGS)" \ -o bin/darwin/amd64/$(CLI_EXE) $(CLI_PKG)