From 8922b56c70f92f29a9bbd72a4e8a13fd8b8c4197 Mon Sep 17 00:00:00 2001 From: Lan Tian Date: Sat, 9 Sep 2023 01:58:02 -0700 Subject: [PATCH] Move to GitHub Actions --- .circleci/config.yml | 27 --------- .drone.jsonnet | 101 --------------------------------- .github/workflows/develop.yaml | 60 ++++++++++++++++++++ .github/workflows/release.yaml | 38 +++++++++++++ Dockerfile | 12 ++++ 5 files changed, 110 insertions(+), 128 deletions(-) delete mode 100644 .circleci/config.yml delete mode 100644 .drone.jsonnet create mode 100644 .github/workflows/develop.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 Dockerfile diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index dfe808a..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,27 +0,0 @@ -version: 2.1 - -jobs: - build-glibc: - docker: - - image: gcc - steps: - - checkout - - run: make - - build-musl: - docker: - - image: gcc - steps: - - checkout - - run: apt-get update - - run: apt-get install -y musl musl-dev musl-tools - - run: git clone https://github.com/sabotage-linux/kernel-headers.git - - run: make CC=musl-gcc CFLAGS="-Ikernel-headers/x86/include" static - -workflows: - build-glibc: - jobs: - - build-glibc - build-musl: - jobs: - - build-musl diff --git a/.drone.jsonnet b/.drone.jsonnet deleted file mode 100644 index cea9087..0000000 --- a/.drone.jsonnet +++ /dev/null @@ -1,101 +0,0 @@ -local DebianCompileJob(image, kernel_headers) = { - "kind": "pipeline", - "type": "docker", - "name": image, - "steps": [ - { - "name": "build", - "image": image, - "commands": [ - "apt-get update", - "DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install build-essential " + kernel_headers, - "make" - ] - }, - { - "name": "telegram notification for failure", - "image": "appleboy/drone-telegram", - "settings": { - "token": { - "from_secret": "tg_token" - }, - "to": { - "from_secret": "tg_target" - }, - "message": "āŒ Build #{{build.number}} of `{{repo.name}}`/" + image + " {{build.status}}.\n\nšŸ“ Commit by {{commit.author}} on `{{commit.branch}}`:\n``` {{commit.message}} ```\n\nšŸŒ {{build.link}}" - }, - "when": { - "status": [ - "failure" - ], - "event": [ - "push" - ] - } - } - ] -}; - -local AlpineCompileJob(image) = { - "kind": "pipeline", - "type": "docker", - "name": image, - "steps": [ - { - "name": "build", - "image": image, - "commands": [ - "apk add --no-cache build-base linux-headers", - "make" - ] - }, - { - "name": "telegram notification for failure", - "image": "appleboy/drone-telegram", - "settings": { - "token": { - "from_secret": "tg_token" - }, - "to": { - "from_secret": "tg_target" - }, - "message": "āŒ Build #{{build.number}} of `{{repo.name}}`/" + image + " {{build.status}}.\n\nšŸ“ Commit by {{commit.author}} on `{{commit.branch}}`:\n``` {{commit.message}} ```\n\nšŸŒ {{build.link}}" - }, - "when": { - "status": [ - "failure" - ], - "event": [ - "push" - ] - } - } - ] -}; - -[ - { - "kind": "secret", - "name": "tg_token", - "get": { - "path": "telegram-token", - "name": "telegram-token" - } - }, - { - "kind": "secret", - "name": "tg_target", - "get": { - "path": "telegram-target", - "name": "telegram-target" - } - }, - DebianCompileJob('debian:buster', 'linux-headers-arm64'), - DebianCompileJob('debian:bullseye', 'linux-headers-arm64'), - DebianCompileJob('debian:bookworm', 'linux-headers-arm64'), - DebianCompileJob('debian:unstable', 'linux-headers-arm64'), - DebianCompileJob('ubuntu:focal', 'linux-headers-generic'), - DebianCompileJob('ubuntu:jammy', 'linux-headers-generic'), - AlpineCompileJob('alpine:edge'), - AlpineCompileJob('alpine:latest'), -] diff --git a/.github/workflows/develop.yaml b/.github/workflows/develop.yaml new file mode 100644 index 0000000..ffc0d99 --- /dev/null +++ b/.github/workflows/develop.yaml @@ -0,0 +1,60 @@ +on: + push: + branches: + - '**' + pull_request: + branches: + - 'master' + +jobs: + build-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Build + run: | + sudo apt-get update + sudo apt-get install -y build-essential linux-headers-generic + make + make clean + make static + make clean + + docker-develop: + runs-on: ubuntu-latest + needs: + - build-test + if: github.event_name != 'pull_request' + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build docker image + uses: docker/build-push-action@v4 + with: + context: '{{defaultContext}}' + platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7 + push: true + tags: | + xddxdd/route-chain:develop + xddxdd/route-chain:develop-${{ github.sha }} + ghcr.io/xddxdd/route-chain:develop + ghcr.io/xddxdd/route-chain:develop-${{ github.sha }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..5c5b8d3 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,38 @@ +on: + release: + types: [created] + +jobs: + docker-release: + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build docker image + uses: docker/build-push-action@v4 + with: + context: '{{defaultContext}}' + platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7 + push: true + tags: | + xddxdd/route-chain:latest + xddxdd/route-chain:${{ github.event.release.tag_name }} + ghcr.io/xddxdd/route-chain:latest + ghcr.io/xddxdd/route-chain:${{ github.event.release.tag_name }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e3127bc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM alpine:edge AS step_0 +WORKDIR /root +COPY . . +RUN apk add --no-cache build-base linux-headers +RUN make static + +################################################################################ + +FROM scratch AS step_1 +ENV PATH=/ +COPY --from=step_0 /root/route-chain / +ENTRYPOINT ["/route-chain"]