Skip to content

Commit

Permalink
Release Refine (#384)
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah authored May 17, 2022
1 parent 5f6a1e7 commit 32f1daa
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 26 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 8 additions & 10 deletions .github/workflows/release-ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,4 +21,4 @@ jobs:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_USER_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 10 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,6 +36,9 @@ archives:
- goos: windows
format: zip

release:
draft: true
prerelease: auto
#signs:
# - artifacts: all
# args: ["--output", "${signature}", "--detach-sign", "--armor", "${artifact}"]
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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="[email protected]"
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
Expand Down
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down

0 comments on commit 32f1daa

Please sign in to comment.