From 091a12c91cc3ba8ff37bb190104ca4e7b7673153 Mon Sep 17 00:00:00 2001 From: David Grove Date: Wed, 3 May 2023 17:00:11 -0400 Subject: [PATCH] update/fix release logic in github actions (#373) Signed-off-by: David Grove --- .github/workflows/ci.yaml | 2 +- .github/workflows/cli-release.yml | 61 ++++++++----------------------- ci/build-cli-release.sh | 1 + 3 files changed, 18 insertions(+), 46 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 86c34d37..4557b49e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -207,4 +207,4 @@ jobs: run: KAR_VERSION=$(git rev-parse --short "$GITHUB_SHA") DOCKER_REGISTRY=quay.io DOCKER_NAMESPACE=ibm DOCKER_IMAGE_TAG=latest make docker - name: Push Release Images if: ${{ env.PUSH_RELEASE == 'true' }} - run: KAR_VERSION=${GITHUB_REF_NAME} DOCKER_REGISTRY=quay.io DOCKER_NAMESPACE=ibm DOCKER_IMAGE_TAG=${GITHUB_REF_NAME} make docker + run: KAR_VERSION=${GITHUB_REF_NAME#v} DOCKER_REGISTRY=quay.io DOCKER_NAMESPACE=ibm DOCKER_IMAGE_TAG=${GITHUB_REF_NAME#v} make docker diff --git a/.github/workflows/cli-release.yml b/.github/workflows/cli-release.yml index 6d36fdab..8555d47d 100644 --- a/.github/workflows/cli-release.yml +++ b/.github/workflows/cli-release.yml @@ -22,6 +22,9 @@ on: name: Make CLI Release +permissions: + contents: write + jobs: build: name: Make CLI Release @@ -29,57 +32,25 @@ jobs: if: github.repository == 'IBM/kar' steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Go uses: actions/setup-go@v4 with: go-version-file: 'core/go.mod' cache-dependency-path: 'core/go.sum' - - name: Get Version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v} + - name: Compute version + run: echo "KAR_VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV" - name: Build CLI run: | - KAR_VERSION=${{ steps.get_version.outputs.VERSION }} ./ci/build-cli-release.sh + echo $KAR_VERSION + ./ci/build-cli-release.sh - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ steps.get_version.outputs.VERSION }} - draft: false - prerelease: false - - name: Upload MacOS amd64 - id: upload-mac-amd64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./core/build/kar-mac-amd64.zip - asset_name: kar-mac-amd64.zip - asset_content_type: application/zip - - name: Upload Windows amd64 - id: upload-windows-amd64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: softprops/action-gh-release@v1 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./core/build/kar-windows-amd64.zip - asset_name: kar-windows-amd64.zip - asset_content_type: application/zip - - name: Upload Linux amd64 - id: upload-linux-amd64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./core/build/kar-linux-amd64.tgz - asset_name: kar-linux-amd64.tgz - asset_content_type: application/gzip - - + name: ${{ env.KAR_VERSION }} + fail_on_unmatched_files: true + files: | + ./core/build/kar-linux-amd64.tgz + ./core/build/kar-mac-amd64.zip + ./core/build/kar-mac-arm64.zip + ./core/build/kar-windows-amd64.zip diff --git a/ci/build-cli-release.sh b/ci/build-cli-release.sh index 0ba8d12b..8a2131a4 100755 --- a/ci/build-cli-release.sh +++ b/ci/build-cli-release.sh @@ -41,5 +41,6 @@ buildOne() { } buildOne "darwin" "amd64" +buildOne "darwin" "arm64" buildOne "linux" "amd64" buildOne "windows" "amd64"