From 7525c0f37f8bb140aeb542d830274a72fca5b210 Mon Sep 17 00:00:00 2001 From: Jason-ZW Date: Tue, 15 Sep 2020 12:51:53 +0800 Subject: [PATCH] feat(autok3s): compress linux amd64/arm64/arm binaries Signed-off-by: Jason-ZW --- .drone.yml | 228 +++++++++++++++++++++++++++++++++++++++++++++-------- README.md | 1 + 2 files changed, 195 insertions(+), 34 deletions(-) diff --git a/.drone.yml b/.drone.yml index 994bb54b..0eea6fb3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -63,7 +63,7 @@ depends_on: - lint --- kind: pipeline -name: build +name: compress-amd64 platform: os: linux arch: amd64 @@ -79,7 +79,25 @@ steps: volumes: - name: docker path: /var/run/docker.sock - - name: github_binary_release + - name: compress + image: maiwj/drone-dapper:v0.4.2 + privileged: true + environment: + BY: dapper + commands: + - wget https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz + - tar -xvf upx-3.96-amd64_linux.tar.xz + - cp upx-3.96-amd64_linux/upx /usr/bin/ + - upx --brute dist/autok3s_linux_amd64 + volumes: + - name: docker + path: /var/run/docker.sock + when: + event: + - tag + depends_on: + - build + - name: github_linux_amd64_binary_release image: ibuildthecloud/github-release:v0.0.1 settings: api_key: @@ -87,42 +105,132 @@ steps: prerelease: true checksum: - sha256 - checksum_file: CHECKSUMsum.txt + checksum_file: CHECKSUMsum-amd64.txt checksum_flatten: true files: - - "dist/autok3s_*" + - "dist/autok3s_linux_amd64" when: event: - tag depends_on: - - build - - name: package + - compress + - name: github_darwin_amd64_binary_release + image: ibuildthecloud/github-release:v0.0.1 + settings: + api_key: + from_secret: github_token + prerelease: true + checksum: + - sha256 + checksum_file: CHECKSUMsum-darwin-amd64.txt + checksum_flatten: true + files: + - "dist/autok3s_darwin_amd64" + when: + event: + - tag + depends_on: + - compress + - name: github_windows_amd64_binary_release + image: ibuildthecloud/github-release:v0.0.1 + settings: + api_key: + from_secret: github_token + prerelease: true + checksum: + - sha256 + checksum_file: CHECKSUMsum-windows-amd64.txt + checksum_flatten: true + files: + - "dist/autok3s_windows_amd64.exe" + when: + event: + - tag + depends_on: + - compress + - name: github_windows_386_binary_release + image: ibuildthecloud/github-release:v0.0.1 + settings: + api_key: + from_secret: github_token + prerelease: true + checksum: + - sha256 + checksum_file: CHECKSUMsum-windows-386.txt + checksum_flatten: true + files: + - "dist/autok3s_windows_386.exe" + when: + event: + - tag + depends_on: + - compress +volumes: + - name: docker + host: + path: /var/run/docker.sock +trigger: + event: + include: + - push + - pull_request + - tag +node: + instance: agent-amd64 +depends_on: + - integration-test +--- +kind: pipeline +name: compress-arm64 +platform: + os: linux + arch: arm64 +steps: + - name: build image: maiwj/drone-dapper:v0.4.2 + privileged: true environment: BY: dapper - DOCKER_USERNAME: - from_secret: docker_username - DOCKER_PASSWORD: - from_secret: docker_password - REPO: cnrancher - WITHOUT_MANIFEST: true commands: - - make autok3s package only - - make autok3s deploy only + - make autok3s build only + volumes: + - name: docker + path: /var/run/docker.sock + - name: compress + image: maiwj/drone-dapper:v0.4.2 + privileged: true + environment: + BY: dapper + commands: + - wget https://github.com/upx/upx/releases/download/v3.96/upx-3.96-arm64_linux.tar.xz + - tar -xvf upx-3.96-arm64_linux.tar.xz + - cp upx-3.96-arm64_linux/upx /usr/bin/ + - upx --brute dist/autok3s_linux_arm64 volumes: - name: docker path: /var/run/docker.sock when: - ref: - include: - - "refs/heads/master" - - "refs/heads/release/v*" - - "refs/tags/v*" event: - exculde: - - pull_request + - tag depends_on: - build + - name: github_binary_release + image: ibuildthecloud/github-release:v0.0.1 + settings: + api_key: + from_secret: github_token + prerelease: true + checksum: + - sha256 + checksum_file: CHECKSUMsum-arm64.txt + checksum_flatten: true + files: + - "dist/autok3s_linux_arm64" + when: + event: + - tag + depends_on: + - compress volumes: - name: docker host: @@ -134,32 +242,82 @@ trigger: - pull_request - tag node: - instance: agent-amd64 + instance: agent-arm64 depends_on: - integration-test --- kind: pipeline -name: manifest +name: compress-arm platform: os: linux - arch: amd64 + arch: arm steps: - - name: push + - name: build image: maiwj/drone-dapper:v0.4.2 + privileged: true environment: BY: dapper - DOCKER_USERNAME: - from_secret: docker_username - DOCKER_PASSWORD: - from_secret: docker_password - REPO: cnrancher - ONLY_MANIFEST: true - CROSS: true commands: - - make autok3s deploy only + - make autok3s build only volumes: - name: docker path: /var/run/docker.sock + - name: compress + image: maiwj/drone-dapper:v0.4.2 + privileged: true + environment: + BY: dapper + commands: + - wget https://github.com/upx/upx/releases/download/v3.96/upx-3.96-arm_linux.tar.xz + - tar -xvf upx-3.96-arm_linux.tar.xz + - cp upx-3.96-arm_linux/upx /usr/bin/ + - upx --brute dist/autok3s_linux_arm + volumes: + - name: docker + path: /var/run/docker.sock + when: + event: + - tag + depends_on: + - build + - name: github_binary_release + image: ibuildthecloud/github-release:v0.0.1 + settings: + api_key: + from_secret: github_token + prerelease: true + checksum: + - sha256 + checksum_file: CHECKSUMsum-arm.txt + checksum_flatten: true + files: + - "dist/autok3s_linux_arm" + when: + event: + - tag + depends_on: + - compress +volumes: + - name: docker + host: + path: /var/run/docker.sock +trigger: + event: + include: + - push + - pull_request + - tag +node: + instance: agent-arm +depends_on: + - integration-test +--- +kind: pipeline +name: manifest +platform: + os: linux + arch: amd64 +steps: - name: release-note image: maiwj/drone-releaser:v0.1.0 commands: @@ -201,4 +359,6 @@ trigger: node: instance: agent-amd64 depends_on: - - build + - compress-amd64 + - compress-arm64 + - compress-arm diff --git a/README.md b/README.md index d3c9147d..488c9fb6 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ Use `Makefile` to manage project compilation, testing and packaging. Of course, you can also choose to compile using `dapper`. Install `dapper` please follow the [dapper](https://github.com/rancher/dapper) project. PRs are welcome. +- vendor: `GO111MODULE=on go mod vendor` - compilation: `BY=dapper make autok3s` - testing: `BY=dapper make autok3s unit` - packing: `BY=dapper make autok3s package only`