Skip to content

release

release #45461

Workflow file for this run

# ------------------------------------------------------------
# Copyright 2021 The Dapr Authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------
name: release
on:
workflow_dispatch:
repository_dispatch:
types: update
schedule:
- cron: '0 * * * *'
jobs:
build:
name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macOS-latest]
target_arch: [amd64]
include:
- os: macOS-latest
target_os: darwin
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Check Homebrew installation
run: brew help
- name: Create artifact directory
run: mkdir -p release && touch release/version.txt
- name: Fetch latest released version for Dapr Cli.
env:
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
run: |
DAPR_CLI_VERSION=$( curl -s -f "https://x-access-token:${GITHUB_TOKEN}@api.github.com/repos/dapr/cli/releases" | grep \"tag_name\" | awk 'NR==1{print $2}' | sed -n 's/\"v\(.*\)\",/\1/p' )
echo "Found version ${DAPR_CLI_VERSION}"
echo "DAPR_CLI_VERSION=$DAPR_CLI_VERSION" >> $GITHUB_ENV
- name: Generate filename.
run: |
FORMULA_FILENAME=$( bash ./.github/scripts/generate-filename.sh )
echo "FORMULA_FILENAME=$FORMULA_FILENAME" >> $GITHUB_ENV
- name: Generate formula name.
run: |
FORMULA_NAME=$( bash ./.github/scripts/generate-formula-name.sh )
echo "FORMULA_NAME=$FORMULA_NAME" >> $GITHUB_ENV
- name: Generate formula name.
run: |
FORMULA_CLASSNAME=$( bash ./.github/scripts/generate-formula-classname.sh )
echo "FORMULA_CLASSNAME=$FORMULA_CLASSNAME" >> $GITHUB_ENV
- name: Check if Dapr Cli's version is new.
run: |
NEW_VERSION=$( cat ${FORMULA_FILENAME} | grep "version " | grep "'${DAPR_CLI_VERSION}'" &> /dev/null || echo "yes" )
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Get Dapr Cli's source code tarball's shasum.
env:
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
if: env.NEW_VERSION == 'yes'
run: |
DAPR_CLI_SRC_SHASUM=$( curl -L -f "https://x-access-token:${GITHUB_TOKEN}@github.com/dapr/cli/archive/v${DAPR_CLI_VERSION}.tar.gz" 2> /dev/null | shasum -a 256 | cut -d\- -f1 | xargs -I {} echo {} )
echo "DAPR_CLI_SRC_SHASUM=$DAPR_CLI_SRC_SHASUM" >> $GITHUB_ENV
- name: Get Homebrew's tap for Dapr Cli.
if: env.NEW_VERSION == 'yes'
run: brew tap dapr/tap && brew update
- name: Generating initial formula for new version.
if: env.NEW_VERSION == 'yes'
run: bash ./.github/scripts/generate-temp-formula.sh
- name: Setup Go
if: env.NEW_VERSION == 'yes'
run: |
brew unlink go@1.15 || echo "Could not unlink Go@1.15"
# Go might fail just to symlink.
brew install go || echo "Installing Go might have failed"
brew link --overwrite go
go version
- name: Generating Homebrew's bottle file for Dapr Cli.
if: env.NEW_VERSION == 'yes'
run: |
brew install ${{ env.FORMULA_NAME }} --build-bottle && brew bottle ${{ env.FORMULA_NAME }}
generated_bottle_filename=$( ls -1 *.bottle.*tar.gz )
bottle_filename=$( echo $generated_bottle_filename | sed -e 's/--/-/' | sed -e 's/\.1\.tar.gz/.tar.gz/' )
DAPR_CLI_BOTTLE_OS_VERSION=$( echo $generated_bottle_filename | sed -e 's/--/-/' | sed -e 's/.*\.\(.*\)\.bottle.*/\1/' )
mv $generated_bottle_filename $bottle_filename
DAPR_CLI_BOTTLE_SHASUM=$( shasum -a 256 ${bottle_filename} | sed -n "s/\(.*\) ${bottle_filename}/\1/p" | xargs -I {} echo {} )
mkdir -p release
mv $bottle_filename release/$bottle_filename
echo ${DAPR_CLI_VERSION} > release/version.txt
echo "DAPR_CLI_BOTTLE_OS_VERSION=$DAPR_CLI_BOTTLE_OS_VERSION" >> $GITHUB_ENV
echo "DAPR_CLI_BOTTLE_SHASUM=$DAPR_CLI_BOTTLE_SHASUM" >> $GITHUB_ENV
- name: Generating initial formula for new version.
if: env.NEW_VERSION == 'yes'
run: bash ./.github/scripts/generate-formula.sh
- name: Release artifacts
uses: actions/upload-artifact@master
with:
name: bottle_drop
path: ./release
- name: Commit to repository
if: env.NEW_VERSION == 'yes'
env:
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
COMMIT_MSG: |
Updating ${{ env.FORMULA_NAME }} formula for version ${{ env.DAPR_CLI_VERSION }}
skip-checks: true
run: |
git config user.email "Dapr Bot"
git config user.name "daprweb@microsoft.com"
# Update origin with token
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
# Checkout the branch so we can push back to it
git checkout master
git fetch origin
git add .
# Only commit and push if we have changes
git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git pull --rebase; git push origin master)
git tag v${{env.DAPR_CLI_VERSION}}
git push origin --tags
publish:
name: Publish binaries
needs: build
env:
ARTIFACT_DIR: ./release
runs-on: ubuntu-latest
steps:
- name: download artifacts
uses: actions/download-artifact@master
with:
name: bottle_drop
path: ${{ env.ARTIFACT_DIR }}
- name: Set Release Version
run: |
REL_VERSION_FILE="${{ env.ARTIFACT_DIR }}/version.txt"
REL_VER=`cat ${REL_VERSION_FILE}`
echo "REL_VERSION=${REL_VER}" >> $GITHUB_ENV
rm -f ${REL_VERSION_FILE}
- name: publish binaries to github
if: env.REL_VERSION != ''
env:
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
run: |
echo "installing github-release-cli..."
sudo npm install --slient --no-progress -g github-release-cli@1.3.1
# Get the list of files
RELEASE_ARTIFACT=(${ARTIFACT_DIR}/*)
# Parse repository to get owner and repo names
OWNER_NAME="${GITHUB_REPOSITORY%%/*}"
REPO_NAME="${GITHUB_REPOSITORY#*/}"
echo "Uploading Dapr CLI Binaries to GitHub Release"
github-release upload \
--owner $OWNER_NAME --repo $REPO_NAME \
--tag "v${REL_VERSION}" \
--name "Dapr CLI v${REL_VERSION}" \
--prerelease false \
${RELEASE_ARTIFACT[*]}