mirror of
https://github.com/kerberos-io/agent.git
synced 2025-12-24 13:07:58 +08:00
112 lines
3.5 KiB
YAML
112 lines
3.5 KiB
YAML
name: Build pull request
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize]
|
|
|
|
env:
|
|
REPO: kerberos/agent
|
|
|
|
jobs:
|
|
build-amd64:
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
contents: write
|
|
strategy:
|
|
matrix:
|
|
architecture: [amd64]
|
|
steps:
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v2
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- uses: benjlevesque/short-sha@v2.1
|
|
id: short-sha
|
|
with:
|
|
length: 7
|
|
- name: Run Build
|
|
run: |
|
|
docker build -t ${{matrix.architecture}} .
|
|
CID=$(docker create ${{matrix.architecture}})
|
|
docker cp ${CID}:/home/agent ./output-${{matrix.architecture}}
|
|
docker rm ${CID}
|
|
- name: Strip binary
|
|
run: tar -cf agent-${{matrix.architecture}}.tar -C output-${{matrix.architecture}} . && rm -rf output-${{matrix.architecture}}
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: agent-${{matrix.architecture}}.tar
|
|
path: agent-${{matrix.architecture}}.tar
|
|
|
|
build-arm64:
|
|
runs-on: ubuntu-24.04-arm
|
|
permissions:
|
|
contents: write
|
|
strategy:
|
|
matrix:
|
|
architecture: [arm64]
|
|
steps:
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v2
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- uses: benjlevesque/short-sha@v2.1
|
|
id: short-sha
|
|
with:
|
|
length: 7
|
|
- name: Run Build
|
|
run: |
|
|
docker build -t ${{matrix.architecture}} -f Dockerfile.arm64 .
|
|
CID=$(docker create ${{matrix.architecture}})
|
|
docker cp ${CID}:/home/agent ./output-${{matrix.architecture}}
|
|
docker rm ${CID}
|
|
- name: Strip binary
|
|
run: tar -cf agent-${{matrix.architecture}}.tar -C output-${{matrix.architecture}} . && rm -rf output-${{matrix.architecture}}
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: agent-${{matrix.architecture}}.tar
|
|
path: agent-${{matrix.architecture}}.tar
|
|
|
|
build-darwin:
|
|
runs-on: macos-13
|
|
permissions:
|
|
contents: write
|
|
strategy:
|
|
matrix:
|
|
architecture: [arm64]
|
|
steps:
|
|
- name: Setup Docker on macOS
|
|
uses: douglascamata/setup-docker-macos-action@v1.0.0
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v2
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- uses: benjlevesque/short-sha@v2.1
|
|
id: short-sha
|
|
with:
|
|
length: 7
|
|
- name: Build Darwin binary with Docker
|
|
run: |
|
|
docker build -f Dockerfile.arm64 \
|
|
-t darwin-${{matrix.architecture}} .
|
|
CID=$(docker create darwin-${{matrix.architecture}})
|
|
docker cp ${CID}:/home/agent ./output-${{matrix.architecture}}
|
|
docker rm ${CID}
|
|
- name: Tar Darwin binary and clean
|
|
run: tar -cf agent-darwin-${{matrix.architecture}}.tar -C output-${{matrix.architecture}} . && rm -rf output-${{matrix.architecture}}
|
|
- name: Upload darwin artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: agent-darwin-${{matrix.architecture}}.tar
|
|
path: agent-darwin-${{matrix.architecture}}.tar
|
|
|