Skip to content

Commit

Permalink
ci: Automate releasing via bob (hashicorp#1167)
Browse files Browse the repository at this point in the history
* ci: Automate releasing via bob

* CONTRIBUTING: remove outdated release step
  • Loading branch information
radeksimko authored Dec 19, 2023
1 parent 092ab28 commit f76188d
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 28 deletions.
32 changes: 4 additions & 28 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,31 +205,7 @@ Release process:

1. Update [`version/VERSION`](https://github.com/hashicorp/terraform-ls/blob/main/version/VERSION) to remove `-dev` suffix and set it to the intended version to be released
1. Wait for [`build` workflow](https://github.com/hashicorp/terraform-ls/actions/workflows/build.yml) and dependent `prepare` workflow to finish
1. Ensure you have the appropriate GitHub PAT set in `BOB_GITHUB_TOKEN` variable
1. Set `SHA` to the corresponding (long) last commit SHA (after updating `VERSION` file) & `VERSION` to the same version
1. Use `bob` to promote artifacts to **staging**
```
bob trigger-promotion \
--product-name=terraform-ls \
--environment=terraform-ls-oss \
--org=hashicorp \
--repo=terraform-ls \
--slack-channel=C02AGQXCAF5 \
--product-version="$VERSION" \
--sha="$SHA" \
--branch=main \
staging
```
1. Use `bob` to promote artifacts to **production**
```
bob trigger-promotion \
--product-name=terraform-ls \
--environment=terraform-ls-oss \
--org=hashicorp \
--repo=terraform-ls \
--slack-channel=C02AGQXCAF5 \
--product-version="$VERSION" \
--sha="$SHA" \
--branch=main \
production
```
1. Run the [Release workflow](https://github.com/hashicorp/terraform-ls/actions/workflows/release.yml) with the appropriate version (matching the one in `version/VERSION`) & SHA (long one).
1. Wait for `staging` release [is finished](https://github.com/hashicorp/crt-workflows-common/actions/workflows/crt-promote-staging.yml).
1. Wait for a message in the Slack channel saying that authorisation is needed to promote artifacts to production. Click on the link and approve.

73 changes: 73 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
type: string
sha:
description: 'SHA'
required: true
type: string
branch:
description: 'Branch'
type: string
default: main

jobs:
staging:
runs-on: ubuntu-latest
steps:
- name: Setup bob
uses: hashicorp/action-setup-bob@v1
with:
github-token:
${{ secrets.BOB_GITHUB_TOKEN }}
- name: Promote to staging
env:
BOB_GITHUB_TOKEN: ${{ secrets.BOB_GITHUB_TOKEN }}
VERSION: ${{ github.event.inputs.version }}
SHA: ${{ github.event.inputs.sha }}
BRANCH: main
ENVIRONMENT: staging
run: |
bob trigger-promotion \
--product-name=terraform-ls \
--environment=terraform-ls-oss \
--org=hashicorp \
--repo=terraform-ls \
--slack-channel=C02AGQXCAF5 \
--product-version=$VERSION \
--sha=$SHA \
--branch=$BRANCH \
$ENVIRONMENT
production:
runs-on: ubuntu-latest
needs: staging
steps:
- name: Setup bob
uses: hashicorp/action-setup-bob@v1
with:
github-token:
${{ secrets.BOB_GITHUB_TOKEN }}
- name: Promote to production
env:
BOB_GITHUB_TOKEN: ${{ secrets.BOB_GITHUB_TOKEN }}
VERSION: ${{ github.event.inputs.version }}
SHA: ${{ github.event.inputs.sha }}
BRANCH: main
ENVIRONMENT: production
run: |
bob trigger-promotion \
--product-name=terraform-ls \
--environment=terraform-ls-oss \
--org=hashicorp \
--repo=terraform-ls \
--slack-channel=C02AGQXCAF5 \
--product-version=$VERSION \
--sha=$SHA \
--branch=$BRANCH \
$ENVIRONMENT

0 comments on commit f76188d

Please sign in to comment.