From 4f86ed623aa32f47b0b111d191a0fc2680ddd58e Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Mon, 18 Jan 2021 14:43:07 +0900 Subject: [PATCH] add .github/workflows/release.yml Signed-off-by: Akihiro Suda --- .github/workflows/release.yml | 49 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 13 ++++++++++ .gitignore | 1 + Makefile | 14 ++++++++-- 4 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..69ff7bb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: Release +on: + push: + tags: + - 'v*' + - 'test-action-release-*' +env: + GO111MODULE: on +jobs: + release: + runs-on: ubuntu-20.04 + timeout-minutes: 20 + steps: + - uses: actions/setup-go@v2 + with: + go-version: 1.15.x + - uses: actions/checkout@v2 + - name: "Compile binaries" + run: make artifacts + - name: "SHA256SUMS" + run: | + ( cd _artifacts; sha256sum cni-isolation-* ) | tee /tmp/SHA256SUMS + mv /tmp/SHA256SUMS _artifacts/SHA256SUMS + - name: "The sha256sum of the SHA256SUMS file" + run: (cd _artifacts; sha256sum SHA256SUMS) + - name: "Prepare the release note" + run: | + tag="${GITHUB_REF##*/}" + shasha=$(sha256sum _artifacts/SHA256SUMS | awk '{print $1}') + cat << EOF | tee /tmp/release-note.txt + ${tag} + + #### Changes + (To be documented) + + #### About the binaries + The binaries were built automatically on GitHub Actions. + The build log is available for 90 days: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + + The sha256sum of the SHA256SUMS file itself is \`${shasha}\` . + EOF + - name: "Create release" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + tag="${GITHUB_REF##*/}" + asset_flags=() + for f in _artifacts/*; do asset_flags+=("-a" "$f"); done + hub release create "${asset_flags[@]}" -F /tmp/release-note.txt --draft "${tag}" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c70af78..18bd86d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,19 @@ jobs: version: v1.35 args: --verbose + cross: + runs-on: ubuntu-20.04 + timeout-minutes: 20 + steps: + - uses: actions/setup-go@v2 + with: + go-version: 1.15.x + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + - name: "Cross" + run: make artifacts + test: runs-on: ubuntu-20.04 timeout-minutes: 20 diff --git a/.gitignore b/.gitignore index 222828d..c96b846 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /bin *.test +_artifacts diff --git a/Makefile b/Makefile index 5aceb94..b800baf 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,17 @@ bin/isolation: mkdir -p bin $(GO_BUILD) -o bin/isolation ./plugins/meta/isolation +# arch: https://github.com/containernetworking/plugins/blob/e13bab99e54b4a34375450518d7db7a3da825e44/scripts/release.sh#L24 +artifacts: + make clean + mkdir _artifacts + for arch in amd64 arm arm64 ppc64le s390x mips64le; do \ + GOARCH=$$arch make ; \ + tar czvf _artifacts/cni-isolation-$${arch}.tgz --owner=0 --group=0 -C bin isolation ; \ + rm -rf bin ; \ + done + clean: - rm -rf bin + rm -rf bin _artifacts -.PHONY: binary install uninstall bin/isolation clean +.PHONY: binary install uninstall bin/isolation artifacts clean