create_release #90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: create_release | |
on: | |
workflow_dispatch: | |
inputs: | |
sha: | |
required: true | |
type: string | |
description: The git SHA of the artifacts in Artifactory to be used in this release | |
version: | |
required: true | |
type: string | |
description: The version number to be used in this release (e.g. 0.0.1) | |
channel: | |
required: true | |
type: choice | |
description: The Artifactory repo from which to download the release assets | |
default: stable | |
options: | |
- dev | |
- stable | |
- staging | |
pre_release: | |
required: false | |
type: boolean | |
default: false | |
description: To mark this as a pre-release, check this box. | |
jobs: | |
create-release: | |
name: Create Release | |
runs-on: ubuntu-latest | |
env: | |
GOPRIVATE: 'github.com/hashicorp/*' | |
GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }} | |
ARTIFACTORY_TOKEN: ${{ secrets.QUALITY_TEAM_ARTIFACTORY_TOKEN }} | |
ARTIFACTORY_USER: ${{ secrets.QUALITY_TEAM_ARTIFACTORY_USER }} | |
PRODUCT: ${{ github.event.repository.name }} | |
SHA: ${{ github.event.inputs.sha }} | |
VERSION: ${{ github.event.inputs.version }} | |
CHANNEL: ${{ github.event.inputs.channel }} | |
PRE_RELEASE: ${{ github.event.inputs.pre_release }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
# Set up bob CLI | |
- name: Setup bob CLI | |
uses: hashicorp/action-setup-bob@v1 | |
with: | |
github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }} | |
# Use bob to download artifacts from Artifactory | |
- name: Download artifacts | |
env: | |
BOB_ARTIFACTORY_TOKEN: ${{ secrets.QUALITY_TEAM_ARTIFACTORY_TOKEN }} | |
BOB_ARTIFACTORY_USER: ${{ secrets.QUALITY_TEAM_ARTIFACTORY_USER }} | |
run: | | |
bob download artifactory \ | |
-channel ${{ env.CHANNEL }} \ | |
-commit=${{ env.SHA }} \ | |
-product-name=${{ env.PRODUCT }} \ | |
-product-version=${{ env.VERSION }} \ | |
-pattern="${{ env.PRODUCT }}_${{ env.VERSION }}_*_*.zip" | |
# Confirm that artifacts have been downloaded | |
- name: Confirm | |
run: ls .bob/artifacts | |
# Create a release. If `pre-release` box is checked, add the `--pre-release` flag and create a | |
# pre-release tag as `v<version>-pre+<first 5 characters of SHA>`. | |
- name: Create release | |
run: | | |
export TAG=v${{ env.VERSION }} | |
PRERELEASE="" | |
if [ ${{ env.PRE_RELEASE }} = true ]; then | |
PRERELEASE="--prerelease" | |
TAG=v${{ env.VERSION }}-pre+$( echo ${{ env.SHA }} | head -c 5 ) | |
fi | |
eval gh release create "$TAG" --target ${{ env.SHA }} --generate-notes "$PRERELEASE" ./.bob/artifacts/*.zip | |
# If not a pre-release, generate an updated Homebrew formula definition file | |
# and open a PR on hashicorp/homebrew-internal with the updated file | |
trigger-homebrew-formula-update: | |
if: ${{ github.event.inputs.pre_release == 'false' }} | |
name: Trigger update to Homebrew formula | |
needs: create-release | |
uses: ./.github/workflows/update_homebrew_formula.yml | |
with: | |
channel: ${{ github.event.inputs.channel }} | |
sha: ${{ github.event.inputs.sha }} | |
product: ${{ github.event.repository.name }} | |
version: ${{ github.event.inputs.version }} | |
secrets: inherit |