diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 70c6fa774d44a..c0a78bd3d998d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,9 +1,19 @@ --- name: CI -'on': - - push - - pull_request +on: + push: + tags: + - '*' + branches: + - master + - fork-master + - 'release-*' + pull_request: + branches: + - master + - fork-master + - 'release-*' env: GOPROXY: https://proxy.golang.org @@ -18,7 +28,16 @@ jobs: with: go-version: 1.16.7 - - uses: actions/checkout@v2 + - name: checkout full + uses: actions/checkout@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + path: ${{ env.GOPATH }}/src/k8s.io/kops + fetch-depth: 0 + + - name: checkout shallow + uses: actions/checkout@v2 + if: startsWith(github.ref, 'refs/tags/') == false with: path: ${{ env.GOPATH }}/src/k8s.io/kops @@ -27,39 +46,84 @@ jobs: run: | make all examples test + - name: upload linux binary + if: startsWith(github.ref, 'refs/tags/') + uses: actions/upload-artifact@v2 + with: + name: kops-linux-amd64 + path: ${{ env.GOPATH }}/src/k8s.io/kops/.build/local/kops + if-no-files-found: error + retention-days: 1 + build-macos-amd64: runs-on: macos-10.15 steps: - - name: Set up go - uses: actions/setup-go@v2 - with: - go-version: 1.16.7 + - name: Set up go + uses: actions/setup-go@v2 + with: + go-version: 1.16.7 - - uses: actions/checkout@v2 - with: - path: ${{ env.GOPATH }}/src/k8s.io/kops + - name: checkout full + uses: actions/checkout@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + path: ${{ env.GOPATH }}/src/k8s.io/kops + fetch-depth: 0 + + - name: checkout shallow + uses: actions/checkout@v2 + if: startsWith(github.ref, 'refs/tags/') == false + with: + path: ${{ env.GOPATH }}/src/k8s.io/kops - - name: make kops examples test - working-directory: ${{ env.GOPATH }}/src/k8s.io/kops - run: | - make kops examples test + - name: make kops examples test + working-directory: ${{ env.GOPATH }}/src/k8s.io/kops + run: | + make kops examples test + + - name: upload macos binary + if: startsWith(github.ref, 'refs/tags/') + uses: actions/upload-artifact@v2 + with: + name: kops-darwin-amd64 + path: ${{ env.GOPATH }}/src/k8s.io/kops/.build/local/kops + if-no-files-found: error + retention-days: 1 build-windows-amd64: runs-on: windows-2019 steps: - - name: Set up go - uses: actions/setup-go@v2 - with: - go-version: 1.16.7 + - name: Set up go + uses: actions/setup-go@v2 + with: + go-version: 1.16.7 + + - name: checkout full + uses: actions/checkout@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + path: ${{ env.GOPATH }}/src/k8s.io/kops + fetch-depth: 0 - - uses: actions/checkout@v2 - with: - path: ${{ env.GOPATH }}/src/k8s.io/kops + - name: checkout shallow + uses: actions/checkout@v2 + if: startsWith(github.ref, 'refs/tags/') == false + with: + path: ${{ env.GOPATH }}/src/k8s.io/kops - - name: make kops examples test - working-directory: ${{ env.GOPATH }}/src/k8s.io/kops - run: | - make kops examples test-windows + - name: make kops examples test + working-directory: ${{ env.GOPATH }}/src/k8s.io/kops + run: | + make kops examples test-windows + + - name: upload windows binary + if: startsWith(github.ref, 'refs/tags/') + uses: actions/upload-artifact@v2 + with: + name: kops-windows-amd64 + path: ${{ env.GOPATH }}/src/k8s.io/kops/.build/local/kops + if-no-files-found: error + retention-days: 1 verify: runs-on: ubuntu-20.04 @@ -77,3 +141,30 @@ jobs: working-directory: ${{ env.GOPATH }}/src/k8s.io/kops run: | make quick-ci + + release: + runs-on: ubuntu-20.04 + if: startsWith(github.ref, 'refs/tags/') + needs: + - build-linux-amd64 + - build-macos-amd64 + - build-windows-amd64 + - verify + steps: + - name: Download all kops binary artifacts + uses: actions/download-artifact@v2 + + - name: rename kops binary artifacts + run: | + mv kops-linux-amd64/kops kops-linux-amd64/kops-linux-amd64 + mv kops-darwin-amd64/kops kops-darwin-amd64/kops-darwin-amd64 + mv kops-windows-amd64/kops kops-windows-amd64/kops-windows-amd64 + + - name: Release + uses: softprops/action-gh-release@v1 + with: + fail_on_unmatched_files: true + files: | + kops-linux-amd64/kops-linux-amd64 + kops-darwin-amd64/kops-darwin-amd64 + kops-windows-amd64/kops-windows-amd64 diff --git a/tools/get_version.sh b/tools/get_version.sh index 46fdfd44084d3..52144e698b051 100755 --- a/tools/get_version.sh +++ b/tools/get_version.sh @@ -36,6 +36,7 @@ if [[ -n "${CI}" ]]; then EXACT_TAG=$(git describe --tags --exact-match 2>/dev/null || true) if [[ -n "${EXACT_TAG}" ]]; then VERSION="${EXACT_TAG#v}" # Remove the v prefix from the git tag + VERSION="${VERSION//-bearingpoint*/}" # remove the bearingpoint version from the tag if [[ "${VERSION}" != "${KOPS_RELEASE_VERSION}" ]]; then echo "Build was tagged with ${VERSION}, but version.go had version ${KOPS_RELEASE_VERSION}" exit 1