Skip to content

Commit

Permalink
Add release action
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrouwerdigibase committed Mar 29, 2024
1 parent f0c2aeb commit 1431c92
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
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: Extract version
id: extract_version
run: echo "::set-output name=version::$(echo ${GITHUB_REF#refs/tags/})"

- name: Check version format
id: check_version
run: echo "::set-output name=is_valid::$(if [[ "${{ steps.extract_version.outputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo 'true'; else echo 'false'; fi)"

- name: Update version in bt_ifcmanager.rb
if: steps.check_version.outputs.is_valid == 'true'
run: |
VERSION=${{ steps.extract_version.outputs.version }}
sed -i "s/VERSION = '.*'/VERSION = '$VERSION'/" src/bt_ifcmanager.rb
- name: Commit changes
if: steps.check_version.outputs.is_valid == 'true'
run: |
VERSION=${{ steps.extract_version.outputs.version }}
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -m "Update version to $VERSION" -a
- name: Push changes
if: steps.check_version.outputs.is_valid == 'true'
run: git push

- name: Create RBZ file
if: steps.check_version.outputs.is_valid == 'true'
run: |
VERSION=${{ steps.extract_version.outputs.version }}
RBZ_FILE=bt_ifcmanager-$VERSION.rbz
zip -r $RBZ_FILE src/
- name: Generate release notes
id: generate_notes
run: |
VERSION=${{ steps.extract_version.outputs.version }}
PREVIOUS_TAG=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`)
RELEASE_NOTES=$(git log --pretty=format:"- %s" $PREVIOUS_TAG..HEAD)
echo "::set-output name=notes::$RELEASE_NOTES"
- name: Create Release
if: steps.check_version.outputs.is_valid == 'true'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.extract_version.outputs.version }}
release_name: Sketchup-IFC-Manager ${{ steps.extract_version.outputs.version }}
body: ${{ steps.generate_notes.outputs.notes }}
draft: true
prerelease: false

- name: Upload Release Asset
if: steps.check_version.outputs.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-${{ steps.extract_version.outputs.version }}.rbz
asset_name: bt_ifcmanager-${{ steps.extract_version.outputs.version }}.rbz
asset_content_type: application/zip

0 comments on commit 1431c92

Please sign in to comment.