From a3fde534e228e6de5c890dacf95490e749bde97d Mon Sep 17 00:00:00 2001 From: Shaunak Deshmukh Date: Thu, 18 Aug 2022 16:08:39 +0530 Subject: [PATCH] Add Github actions release CI (#2505) Co-authored-by: shaunak_deshmukh --- .github/workflows/release.yaml | 66 ++++++++++++++++++++++++++++++++++ .goreleaser.yml | 7 ++-- hack/release.sh | 10 ++++-- 3 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..d6b23f81 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,66 @@ +name: Create Draft release +on: + push: + tags: + - v1.** + - v2.** + +env: + GO_VERSION: 1.18.1 + KIND_VERSION: v0.14.0 + KIND_NODE_IMAGE_TAG: v1.19.16 + +jobs: + create-draft-release: + runs-on: ubuntu-latest + steps: + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Check out code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + + - name: Install GoReleaser + uses: goreleaser/goreleaser-action@v3 + with: + install-only: true + + + - name: Kind Clutser + uses: engineerd/setup-kind@v0.5.0 + with: + image: kindest/node:${{ env.KIND_NODE_IMAGE_TAG }} + version: ${{ env.KIND_VERSION }} + config: kind.yaml + + - name: Generate CRDs + run: make generate-crds + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Docker Login + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v3 + with: + version: latest + args: release + env: + GORELEASER_CURRENT_TAG: ${{ steps.get_version.outputs.VERSION }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCKER_CLI_EXPERIMENTAL: "enabled" + + #ToDo - Verify and upload releases \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml index c18cb0b4..4bd37def 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -8,7 +8,6 @@ release: header: | Release Highlights: https://fission.io/docs/releases/{{ .Tag }}/ Install Guide: https://fission.io/docs/installation/ - Full Changelog: https://github.com/fission/fission/blob/master/CHANGELOG.md extra_files: - glob: ./manifest/charts/* - glob: ./manifest/yamls/* @@ -27,9 +26,9 @@ builds: - -X github.com/fission/fission/pkg/info.BuildDate={{.Date}} - -X github.com/fission/fission/pkg/info.Version={{.Tag}} gcflags: - - all=-trimpath={{.Env.PWD}} + - all=-trimpath={{ if index .Env "GITHUB_WORKSPACE"}}{{ .Env.GITHUB_WORKSPACE }}{{ else }}{{ .Env.PWD }}{{ end }} asmflags: - - all=-trimpath={{.Env.PWD}} + - all=-trimpath={{ if index .Env "GITHUB_WORKSPACE"}}{{ .Env.GITHUB_WORKSPACE }}{{ else }}{{ .Env.PWD }}{{ end }} env: - CGO_ENABLED=0 goos: @@ -258,7 +257,7 @@ docker_manifests: - fission/reporter:latest-arm64 - fission/reporter:latest-armv7 changelog: - skip: true + skip: false archives: - id: fission builds: diff --git a/hack/release.sh b/hack/release.sh index 9607d67e..75008235 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -39,14 +39,17 @@ check_clean() { } check_github_token() { - if [ ! -f "$HOME"/.github-token ]; then - echo "Error finding github access token at ${HOME}/.github-token" + if [ ! -f "$HOME"/.github-token ] && [ -z "$GITHUB_TOKEN" ]; then + echo "Error finding github access token at ${HOME}/.github-token or in GITHUB_TOKEN envvar" exit 1 fi echo "check_github_token == PASSED" } -export GITHUB_TOKEN=$(cat ~/.github-token) +# Read token from file if not set as envvar +if [ -z "$GITHUB_TOKEN"]; then + export GITHUB_TOKEN=$(cat ~/.github-token) +fi version=$1 if [ -z "$version" ]; then @@ -66,6 +69,7 @@ check_github_token export GORELEASER_CURRENT_TAG=$version echo "Release version $GORELEASER_CURRENT_TAG " +echo "DOCKER_CLI_EXPERIMENTAL $DOCKER_CLI_EXPERIMENTAL" goreleaser release echo "############ DONE #############"