Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add create-release workflow #411

Merged
merged 1 commit into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/scripts/prepare_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# Fail on first error.
set -e

releaseLevel="$1"

npx lerna version "$releaseLevel" --conventional-commits --no-push --no-git-tag-version --yes
57 changes: 57 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Create release candidate

on:
workflow_dispatch:
inputs:
releaseLevel:
description: 'Release level: major, minor, or patch.'
required: true
default: 'patch'

jobs:
create_release:
name: Create release
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Run preparation script
run: bash .github/scripts/prepare_release.sh ${{ github.event.inputs.releaseLevel }}
env:
CHANGELOG_VERSION: ${{ secrets.CHANGELOG_VERSION }}
STD_VERSION_VERSION: ${{ secrets.STD_VERSION_VERSION }}

- name: Get version for later steps
id: get-new-version
run: echo ::set-output name=version::$(node -pe 'require("./lerna.json").version')

- name: Create release commit
run: |
git config user.name "${{ secrets.ADT_API_RELEASE_NAME }}"
git config user.email "${{ secrets.ADT_API_RELEASE_EMAIL }}"
git commit -am "chore: release v${{ steps.get-new-version.outputs.version }}"
# create-pull-request has no way of setting the target branch that won't also
# get rid of all commits (aside from the release commit).
# So, we have to be on master and manually grab all the changes.
# We do that by just telling git "master is now develop (+ the release commit)".
- name: Update local master from develop
run: |
commitHash="$(git log -1 --format='%H')"
git checkout master
git reset --hard "$commitHash"
- name: Create pull request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: release
branch-suffix: timestamp
base: master
title: "chore: release v${{ steps.get-new-version.outputs.version }}"
# If there are any changes not already committed, they will be added to
# a commit with this as the message.
# If there are no changes no commit will be created.
commit-message: "chore: applying release changes"