Release version 5.0.9 #30
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: | |
push: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Check commit message and extract version | |
id: extract_version | |
run: | | |
COMMIT_MESSAGE=$(git log --format=%B -n 1) | |
VERSION=$(echo $COMMIT_MESSAGE | grep -oP 'Release version \K(\d+\.\d+\.\d+)') | |
if [[ -z "$VERSION" ]]; then | |
echo "No version number found in commit message." | |
else | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
echo "IS_VALID=true" >> $GITHUB_ENV | |
fi | |
- name: Debug | |
run: | | |
echo "IS_VALID: $IS_VALID" | |
echo "Version: $VERSION" | |
- name: Update version in bt_ifcmanager.rb | |
if: env.IS_VALID == 'true' | |
run: | | |
sed -i "s/VERSION = '.*'/VERSION = '$VERSION'/" src/bt_ifcmanager.rb | |
- name: Commit changes | |
if: env.IS_VALID == 'true' | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git commit -m "Update version to $VERSION" -a || true | |
- name: Push changes | |
if: env.IS_VALID == 'true' | |
uses: ad-m/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create RBZ file | |
if: env.IS_VALID == 'true' | |
run: | | |
cd src && zip -r "../bt_ifcmanager-${{ env.VERSION }}.rbz" . | |
- name: Generate release notes | |
if: env.IS_VALID == 'true' | |
id: generate_notes | |
run: | | |
PREVIOUS_TAG=$(git describe --tags --abbrev=0) | |
RELEASE_NOTES=$(git log --pretty=format:"- %s" $PREVIOUS_TAG..HEAD) | |
if [[ -z "$RELEASE_NOTES" ]]; then | |
RELEASE_NOTES="No changes since the last release." | |
else | |
RELEASE_NOTES="## What's Changed"$'\n\n'"Release version ${{ env.VERSION }}:"$'\n'"$RELEASE_NOTES"$'\n\n'"**Full Changelog**: https://github.com/BIM-Tools/SketchUp-IFC-Manager/compare/$PREVIOUS_TAG...${{ env.VERSION }}" | |
fi | |
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV | |
echo "$RELEASE_NOTES" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Create Release | |
if: env.IS_VALID == 'true' | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.VERSION }} | |
release_name: Sketchup-IFC-Manager ${{ env.VERSION }} | |
body: ${{ env.RELEASE_NOTES }} | |
draft: true | |
prerelease: false | |
- name: Upload Release Asset | |
if: env.IS_VALID == 'true' | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./bt_ifcmanager-${{ env.VERSION }}.rbz | |
asset_name: bt_ifcmanager-${{ env.VERSION }}.rbz | |
asset_content_type: application/zip |