mathieudutour / mathieudutour/github-tag-action

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

Open
#204 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
733
Forks
227
PR merge metrics
No merged PRs in 30d

Description

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/github-tag-action@v6.1
        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/github-tag-action@v6.1
        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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the two github-tag-action@v6.1 invocations in the workflow, especially how the dry-run output, manifest.json commit, and subsequent tag creation relate. Reproduce the workflow and verify whether the resulting tag contains the manifest update; done means the release tag points to the commit with the updated file, or the limitation is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, github-actions
Domain
ci-cd, release
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.