Create release #20
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: | |
commit_hash: | |
description: "Hash of 'Release version x.y.z' commit" | |
required: true | |
permissions: | |
actions: write | |
contents: write | |
pull-requests: write | |
issues: write | |
jobs: | |
build: | |
name: Create Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Java SDK | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 11 | |
distribution: temurin | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.inputs.commit_hash }} | |
- name: Check commit title and extract version | |
env: | |
COMMIT_HASH: ${{ github.event.inputs.commit_hash }} | |
run: | | |
export commit_title=$(git log --pretty=format:%s -1 $COMMIT_HASH) | |
echo "Commit title: $commit_title" | |
if [[ $commit_title =~ ^Release\ version\ [0-9]*\.[0-9]*\.[0-9]*$ ]]; then | |
echo "Valid commit title" | |
else | |
echo "Invalid commit title" | |
exit 1 | |
fi | |
export version=$(echo ${commit_title} | sed s/^Release\ version\ //g) | |
echo "Will use version ${version}" | |
echo "version=${version}" >> $GITHUB_ENV | |
- name: Build | |
run: | | |
./gradlew clean build | |
- name: Create tag | |
env: | |
VERSION: ${{ env.version }} | |
run: | | |
git config --local user.name "GitHub Action" | |
git config --local user.email "[email protected]" | |
git tag -a "v$VERSION" -m "Release version $VERSION" | |
git push origin "v$VERSION" | |
- name: Create release draft | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "v${{ env.version }}" | |
release_name: "v${{ env.version }}" | |
commitish: ${{ github.event.inputs.commit_hash }} | |
body: | | |
*Fill in* | |
draft: true | |
prerelease: false |