Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GuyKh opened this issue Feb 7, 2024 · 0 comments
Open

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

GuyKh opened this issue Feb 7, 2024 · 0 comments

Comments

@GuyKh
Copy link

GuyKh commented Feb 7, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant