Skip to content

Use target-version in a file, then create the tag of both #204

@GuyKh

Description

@GuyKh

Hey,

I'm developing a custom-component for HomeAssistant and when I want to publish a new version - I have to:

  1. Update the version number in file manifest.json
  2. Create a release for that version.

I wanted to automate the process by creating a manual action where I just select which type of bump do I want to use - and it updates it automatically.

See workflow:

name: Create a Release

on:
  workflow_dispatch:
    inputs:
      bump_type:
        description: 'Bump Release Type'
        required: true
        type: choice
        options:
          - patch
          - minor
          - major

permissions:
  contents: write

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: (DryRun) Bump version and push tag
        id: tag_version_dry_run
        uses: mathieudutour/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          dry_run: true
          default_bump: ${{ github.event.inputs.bump_type}}
          tag_prefix: ''
          release_branches: 'main'
          pre_release_branches: 'main'
          custom_release_rules: |
            "*:${{ github.event.inputs.bump_type}}:Patch"

      - name: Update manifest.json
        run: |
          git config --local user.name "github-actions[bot]"
          git config --local user.email "github-actions[bot]@users.noreply.github.com"
          jq -r ".version = \"${{ steps.tag_version_dry_run.outputs.new_version}}\"" custom_components/ims/manifest.json > custom_components/ims/manifest.json.tmp && mv custom_components/ims/manifest.json.tmp custom_components/ims/manifest.json
          git add custom_components/ims/manifest.json
          git commit -m "[GitHub Action] Bump version to ${{steps.tag_version_dry_run.outputs.new_version}}"
          git remote set-url origin https://guykh:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
          git push origin main # Push the commit

      - name: Bump version and push tag
        id: tag_version
        uses: mathieudutour/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          default_bump: ${{ github.event.inputs.bump_type}}
          tag_prefix: ''
          release_branches: 'main'
          pre_release_branches: 'main'
          custom_release_rules: |
            "*:${{ github.event.inputs.bump_type}}:Patch"

      - name: Create a GitHub release
        uses: ncipollo/release-action@v1
        with:
          tag: ${{ steps.tag_version.outputs.new_version }}
          name: ${{ steps.tag_version.outputs.new_version }}
          body: ${{ steps.tag_version.outputs.changelog }}

As you can see, I run a dry-run to calculate the bumping of the version, update the file, running it again (not dry-run) and creating a Release.

The issue I'm facing is that the tag created (step Bump version and push tag) doesn't include the updating of the manifest.json file.

Any ideas how to solve that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions