diff --git a/.github/workflows/commit-changelog-and-release.yml b/.github/workflows/commit-changelog-and-release.yml index 22b0289..d8bfd88 100644 --- a/.github/workflows/commit-changelog-and-release.yml +++ b/.github/workflows/commit-changelog-and-release.yml @@ -1,26 +1,3 @@ -# Example deploy.yml -# on: -# workflow_dispatch: -# inputs: -# version-tag: -# description: Version tag -# required: true -# default: v0.1.8 # IMPORTANT to have this because we update this. -# dry-run: -# description: Dry run -# type: boolean -# default: false -# -# jobs: -# commit-changelog-and-release: -# uses: ./.github/workflows/commit-changelog-and-release.yml -# with: -# version-tag: ${{ github.event.inputs.version-tag }} -# dry-run: ${{ github.event.inputs.dry-run == 'true' }} -# changelog-path: docs/CHANGELOG.md -# exclude-types: build,docs,style,other -# deploy-yml-path: .github/workflows/deploy.yml - name: Commit CHANGELOG.md and create a Release on: @@ -146,23 +123,3 @@ jobs: name: ${{ inputs.version-tag }} tag: ${{ inputs.version-tag }} body: ${{ steps.changelog.outputs.changes }} - - - name: Modify default next version in deploy.yml inputs - run: | - echo '```diff' >> "$GITHUB_STEP_SUMMARY" - pip install ruamel.yaml - python <(curl https://raw.githubusercontent.com/deargen/workflows/refs/heads/master/scripts/set_next_version_in_deploy_yml.py) \ - ${{ inputs.deploy-yml-path }} \ - ${{ inputs.version-tag }} | tee -a "$GITHUB_STEP_SUMMARY" - echo '```' >> "$GITHUB_STEP_SUMMARY" - - - name: Create Pull Request for updating next version in deploy.yml - uses: peter-evans/create-pull-request@v7 - with: - add-paths: ${{ inputs.deploy-yml-path }} - commit-message: 'chore: update next version in ${{ inputs.deploy-yml-path }} [skip ci]' - title: 'chore: update next version in ${{ inputs.deploy-yml-path }}' - body: | - This PR updates the next version in ${{ inputs.deploy-yml-path }} to ${{ inputs.version-tag }} + 1. - branch: chore/update-deploy-yml - delete-branch: true diff --git a/scripts/set_next_version_in_deploy_yml.py b/scripts/set_next_version_in_deploy_yml.py deleted file mode 100644 index 3d54fb5..0000000 --- a/scripts/set_next_version_in_deploy_yml.py +++ /dev/null @@ -1,70 +0,0 @@ -""" -Update the default version tag in the deploy.yml file. - -```yaml -on: - workflow_dispatch: - inputs: - version-tag: - description: 'Version tag' - required: true - default: 'v0.1.0' # <-- HERE - -# ... -``` -""" - -import sys -from pathlib import Path - -import ruamel.yaml - - -def unidiff_output(expected: str, actual: str): - """Returns a string containing the unified diff of two multiline strings.""" - import difflib - - expected_list = expected.splitlines(keepends=True) - actual_list = actual.splitlines(keepends=True) - - diff = difflib.unified_diff(expected_list, actual_list) - - return "".join(diff) - - -if len(sys.argv) != 3: - print( - "Usage: python increase_version_in_deploy_yml.py " - ) - print( - "Example: python increase_version_in_deploy_yml.py .github/workflows/_deploy.yml v0.1.0" - ) - print( - "This script will set on.workflow_dispatch.inputs.version-tag.default to v0.1.1" - ) - sys.exit(1) - -deploy_yml = sys.argv[1] -current_version = sys.argv[2] - -split_version = current_version.split(".") -last_digit = int(split_version[-1]) -split_version[-1] = str(last_digit + 1) -new_version = ".".join(split_version) - -yaml = ruamel.yaml.YAML() -yaml.preserve_quotes = True -yaml.indent(mapping=2, sequence=4, offset=2) -original_yml_content = Path(deploy_yml).read_text() -with open(deploy_yml) as f: - data = yaml.load(f) -data["on"]["workflow_dispatch"]["inputs"]["version-tag"]["default"] = new_version - -with open(deploy_yml, "w") as f: - yaml.dump(data, f) - -new_yml_content = Path(deploy_yml).read_text() -if original_yml_content == new_yml_content: - print(f"Version was already set to {new_version}") -else: - print(unidiff_output(original_yml_content, new_yml_content))