Create Release #35
Workflow file for this run
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: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version' | |
required: true | |
create-tag: | |
description: 'Create tag' | |
required: true | |
default: 'false' | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: Replace version and service in release_const.py | |
working-directory: ./custom_components/oig_cloud | |
run: | | |
echo 'COMPONENT_VERSION = "${{ github.event.inputs.version }}"' > release_const.py | |
if [ "${{ github.event.inputs.version }}" == "dev" ]; then | |
echo 'SERVICE_NAME = "oig_cloud_dev"' >> release_const.py | |
else | |
echo 'SERVICE_NAME = "oig_cloud"' >> release_const.py | |
fi | |
- name: Update version property in manifest.json | |
working-directory: ./custom_components/oig_cloud | |
run: | | |
if [ "${{ github.event.inputs.version }}" == "dev" ]; then | |
jq --arg version '0.0.0' '.version = $version' manifest.json > manifest.tmp && mv manifest.tmp manifest.json | |
else | |
jq --arg version ${{ github.event.inputs.version }} '.version = $version' manifest.json > manifest.tmp && mv manifest.tmp manifest.json | |
fi | |
- name: Commit changes | |
working-directory: ./custom_components/oig_cloud | |
run: | | |
git config --global user.name "Pavel Simsa" | |
git config --global user.email "[email protected]" | |
git add release_const.py manifest.json | |
git commit -m "Setting release variables to ${{ github.event.inputs.version }}" | |
- name: Push changes | |
working-directory: ./custom_components/oig_cloud | |
if: ${{ github.event.inputs.create-tag != 'true' }} | |
run: | | |
git push | |
- name: Create tag | |
if: ${{ github.event.inputs.create-tag == 'true' }} | |
working-directory: ./custom_components/oig_cloud | |
run: | | |
git tag -a v${{ github.event.inputs.version }} -m "Version ${{ github.event.inputs.version }}" | |
git push --tags | |
- name: Create draft release | |
uses: actions/create-release@v1 | |
if: ${{ github.event.inputs.create-tag == 'true' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ github.event.inputs.version }} | |
release_name: Release ${{ github.event.inputs.version }} | |
draft: true | |