.github/workflows/publish.yml in knife-ionoscloud-5.0.0.beta.1 vs .github/workflows/publish.yml in knife-ionoscloud-5.0.0
- old
+ new
@@ -1,15 +1,13 @@
# Publish workflow
name: Publish
on:
- workflow_dispatch:
- inputs:
- version:
- description: 'Version to publish (e.g. v1.2.3)'
- required: true
+ push:
+ tags:
+ - 'v*'
jobs:
publish:
env:
ruby-version: 2.7
@@ -17,20 +15,14 @@
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
+
+ - name: Unshallow
+ run: git fetch --prune --unshallow
- - name: Validate the version
- shell: bash
- run: |
- if [ "${{ github.event.inputs.version }}" != cat lib/knife-ionoscloud/version.rb | grep 'VERSION =' | tr -s ' ' | cut -d ' ' -f 4 | sed 's/^.//;s/.$//' ]; then
- echo "Specified version does not match the one from version.rb!"
- exit 1
- fi
- echo Next version will be: v${{ github.event.inputs.version }}
-
- name: Setup Ruby
uses: ruby/setup-ruby@v1.61.1
with:
ruby-version: ${{ env.ruby-version }}
@@ -44,15 +36,34 @@
run: bundle
- name: Run the tests
run: rspec
+ - name: Get the new version
+ id: new_version
+ run: echo ::set-output name=VERSION::$(git tag --list "v*" --sort=version:refname | tail -n 1)
+
+ - name: Get the old version
+ id: old_version
+ run: echo ::set-output name=VERSION::$(git tag --list "v*" --sort=version:refname | tail -n 2 | head -n 1)
+
+ - name: Check Version
+ run: |
+ if [ "${{ steps.new_version.outputs.VERSION }}" != v$(cat lib/knife-ionoscloud/version.rb | grep 'VERSION =' | tr -s ' ' | cut -d ' ' -f 4 | sed 's/^.//;s/.$//') ]; then
+ echo "Tag version does not match the one from version.rb!"
+ exit 1
+ fi
+
- name: Create RubyGems release of the Knife plugin
shell: bash
run: |
mkdir -p ~/.gem
cat << EOF > ~/.gem/credentials
---
:rubygems_api_key: ${{ secrets.RUBYGEMS }}
EOF
chmod 0600 ~/.gem/credentials
gem push $(gem build knife-ionoscloud.gemspec | grep 'File' | tr -s ' ' | cut -d ' ' -f 3)
+
+ - name: Check version and create GitHub branch
+ run: |
+ /usr/bin/bash ./git-versioning.sh ${{ steps.new_version.outputs.VERSION }} ${{ steps.old_version.outputs.VERSION }}