Preform minor release of refs/heads/main branch #68
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: Automated Release | |
run-name: "${{ inputs.dry_run && 'Dry-run for ' || 'Preform ' }} ${{ inputs.release_type }} release of ${{ github.ref }} branch" | |
on: | |
workflow_dispatch: | |
inputs: | |
release_type: | |
type: choice | |
description: The release type | |
options: | |
- "major" | |
- "minor" | |
- "patch" | |
default: "minor" | |
dry_run: | |
description: Perform the release dry-run | |
required: true | |
type: boolean | |
default: true | |
jobs: | |
release-branch: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Output Inputs | |
run: | | |
echo "${{ toJSON(github.event.inputs) }}" | |
echo "${{ toJSON(inputs) }}" | |
echo "${{ inputs.release_type }}" | |
- uses: webfactory/ssh-agent@v0.7.0 | |
with: | |
ssh-private-key: ${{ secrets.SSH_PUSH_SECRET }} | |
- name: Checkout ${{ env.GITHUB_REPOSITORY }} | |
run: git clone git@github.com:$GITHUB_REPOSITORY.git java-profiler | |
- name: Configure git env | |
run: | | |
git config --global user.email "java-profiler@datadoghq.com" | |
git config --global user.name "Datadog Java Profiler" | |
- name: Create release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
if [ "${{ inputs.dry_run }}" != "true" ]; then | |
if [ "${{ inputs.release_type }}" != "patch" ]&& [[ ${GITHUB_REF_NAME} =~ release/.* ]]; then | |
echo "::error Only patch release can be performed from a release branch" | |
exit 1 | |
fi | |
if [ "${{ inputs.release_type }}" == "patch" ]&& [[ ! ${GITHUB_REF_NAME} =~ release/.* ]]; then | |
echo "::error::A patch release can be performed only from a release branch" | |
exit 1 | |
fi | |
if [ "${{ inputs.release_type }}" != "patch" ]&& [[ ! ${GITHUB_REF_NAME} =~ main ]]; then | |
echo "::error::A major or minor release can be performed only from 'main' branch" | |
exit 1 | |
fi | |
else | |
DRY_RUN="--dry-run" | |
fi | |
TYPE="${{ inputs.release_type }}" | |
cd java-profiler | |
git checkout $GITHUB_REF_NAME | |
./.github/scripts/release.sh ${TYPE^^} $DRY_RUN |