Merge pull request #30 from ITK-Leantime/release/2.0.0 #28
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: release | |
on: | |
push: | |
tags: | |
- '*.*.*' | |
branches: | |
- '**' | |
permissions: | |
contents: write | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build and create release | |
env: | |
# https://stackoverflow.com/a/71158878/2502647 | |
GH_TOKEN: ${{ github.TOKEN }} | |
run: | | |
is_prerelease=false | |
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/contexts#github-context | |
tag_name="${{ github.ref_name }}" | |
release_name="${tag_name}" | |
# If the type is a branch, then we do a prerelease | |
if [ "${{ github.ref_type }}" == "branch" ]; then | |
is_prerelease=true | |
# Replace everything but letters and numbers in branch name with _ | |
tag_name="dev-${tag_name//[^[:alnum:]-]/_}" | |
release_name="release-${tag_name}" | |
fi | |
docker compose run --user root --rm php bin/create-release "$tag_name" | |
# Delete release if it already exists. | |
gh release view "$release_name" > /dev/null 2>&1 && gh release delete "$release_name" --yes | |
# The package name contains the tag name with any leading `dev-` removed | |
if [ "$is_prerelease" = true ]; then | |
gh release create "$release_name" --prerelease --generate-notes ./*-"${tag_name#dev-}".tar.gz checksum.txt | |
else | |
gh release create "$release_name" --generate-notes ./*-"${tag_name#dev-}".tar.gz checksum.txt | |
fi | |
shell: bash |