Release a New Version #42
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 a New Version | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "New Version. major|minor|patch|rc or an explicit version number." | |
required: true | |
default: patch | |
type: string | |
options: | |
- major | |
- minor | |
- patch | |
- rc | |
env: | |
RUBY_VERSION: 3.1.3 | |
permissions: | |
contents: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref_name }} | |
cancel-in-progress: true | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
outputs: | |
new_version: ${{ steps.bump_version.outputs.new_version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: git-actions/set-user@v1 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{ env.RUBY_VERSION }} | |
bundler-cache: true | |
- name: Bump version | |
id: bump_version | |
run: | | |
bundle config unset deployment | |
ruby -Ilib/openhab/dsl -r version -e 'puts "OLD_VERSION=#{OpenHAB::DSL::VERSION}"' >> $GITHUB_ENV | |
bundle exec gem bump -v ${{ inputs.version }} -m "v%{version}" --file lib/openhab/dsl/version.rb | |
ruby -Ilib/openhab/dsl -r version -e 'puts "NEW_VERSION=#{OpenHAB::DSL::VERSION}"' >> $GITHUB_ENV | |
ruby -Ilib/openhab/dsl -r version -e 'puts "new_version=#{OpenHAB::DSL::VERSION}"' >> $GITHUB_OUTPUT | |
- name: Generate CHANGELOG | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
bin/rake update_doc_links[${{ env.OLD_VERSION }},${{ env.NEW_VERSION }}] | |
gh release create v${{ env.NEW_VERSION }} --generate-notes --draft | |
gh release view v${{ env.NEW_VERSION }} --json body | jq -r .body | sed '1,3d' > new_changes.md | |
gh release delete v${{ env.NEW_VERSION }} --yes | |
bin/rake changelog[${{ env.OLD_VERSION }},${{ env.NEW_VERSION }},new_changes.md] | |
git add Gemfile.lock CHANGELOG.md USAGE.md templates .known_good_references | |
git commit --amend --no-edit | |
git push | |
gh release create v${{ env.NEW_VERSION }} --notes-file new_changes.md | |
# - name: Release Gem | |
# env: | |
# GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }} | |
# run: | | |
# bin/rake release || (git status; false) | |
# publish_main_docs: | |
# needs: release | |
# uses: ./.github/workflows/yardoc.yml | |
# with: | |
# ref_name: main | |
# ref_type: branch | |
# publish_tag_docs: | |
# needs: release | |
# uses: ./.github/workflows/yardoc.yml | |
# with: | |
# ref_name: v${{needs.release.outputs.NEW_VERSION}} | |
# ref_type: tag |