Skip to content

Commit

Permalink
Update reuse-build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Go0p authored May 22, 2024
1 parent f07bf48 commit 0560b00
Showing 1 changed file with 38 additions and 26 deletions.
64 changes: 38 additions & 26 deletions .github/workflows/reuse-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up Docker Buildx and Go
if: inputs.os == 'centos7-amd64'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: |
--driver-opt env=DOCKER_CLI_EXPERIMENTAL=enabled
--name=mybuilder
--driver docker-container
--driver-opt image=docker:20.10.7-git
--driver-opt env=BUILDKIT_STEP_LOG_MAX_SIZE=4096
--buildkitd-flags '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host'
- name: Print Current Directory
run: echo "Current directory is $(pwd)"

- uses: shaowenchen/debugger-action@v2
name: debugger
timeout-minutes: 40
with:
frp_server_addr: ${{ secrets.FRP_SERVER_ADDR }}
frp_server_port: ${{ secrets.FRP_SERVER_PORT }}
frp_token: ${{ secrets.FRP_TOKEN }}
ssh_port: ${{ secrets.SSH_PORT }}


- name: Set up Go
uses: actions/setup-go@v2
if: inputs.os != 'centos7-amd64'
Expand Down Expand Up @@ -111,20 +111,32 @@ jobs:
run: |
go build -ldflags "-s -w -X 'main.goVersion=$(go version)' -X 'main.gitHash=$(git show -s --format=%H)' -X 'main.buildTime=$(git show -s --format=%cd)' -X 'main.yakVersion=${{ env.YAK_TAG }}'" -o ./yak_windows_amd64.exe -v common/yak/cmd/yak.go
if: runner.os == 'Windows'

- name: Build For CentOS 7
if: inputs.os == 'centos7-amd64'

- name: Build and run Docker container
run: |
docker buildx create --use mybuilder
docker buildx build --tag my-go-centos7 --platform linux/amd64 --build-arg GO_VERSION=1.20.3 --file - . <<EOF
FROM centos:7
ARG GO_VERSION
RUN yum -y update && \
yum -y install wget && \
wget https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz && \
tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz && \
ln -s /usr/local/go/bin/go /usr/local/bin/go && \
yum clean all
ENV PATH=$PATH:/usr/local/go/bin
WORKDIR /workspace
COPY . .
RUN go build -ldflags '-linkmode external -extldflags -static -s -w -X main.goVersion=$(go version) -X main.gitHash=12345678 -X main.buildTime=12345678 -X main.yakVersion=v1.3.3' -o ./yak_centos7_amd64 common/yak/cmd/yak.go
EOF
docker run --name my-go-container -d my-go-centos7
- name: Copy built application
run: |
export BUILD_DIR="$PWD"
docker run --rm -v $PWD:/workspace -w /workspace \
-e YAK_TAG=$YAK_TAG \
centos:7 /bin/bash -c "
yum install -y gcc make && \
curl -LO https://golang.org/dl/go1.20.3.linux-amd64.tar.gz && \
tar -C /usr/local -xzf go1.20.3.linux-amd64.tar.gz && \
export PATH=$PATH:/usr/local/go/bin && \
go build -ldflags '-linkmode external -extldflags -static -s -w -X main.goVersion=$(go version) -X main.gitHash=12345678 -X main.buildTime=12345678 -X main.yakVersion=$YAK_TAG' -o ./yak_centos7_amd64 common/yak/cmd/yak.go && \
echo '$BUILD_DIR/yak_centos7_amd64' > /workspace/artifact_path.txt"
docker cp my-go-container:/workspace/yak_centos7_amd64 ./yak_centos7_amd64
docker stop my-go-container
docker rm my-go-container
- name: Read Artifact Path
if: always()
run: |
Expand Down Expand Up @@ -171,7 +183,7 @@ jobs:
if: inputs.os == 'centos7-amd64'
with:
name: yak_centos7_amd64
path: ${{ steps.build.outputs.artifact_path }}
path: ./yak_centos7_amd64



0 comments on commit 0560b00

Please sign in to comment.