{"id":16139623,"url":"https://github.com/hardnorth/github-version-generate","last_synced_at":"2025-03-16T09:33:16.380Z","repository":{"id":40607737,"uuid":"274841032","full_name":"HardNorth/github-version-generate","owner":"HardNorth","description":"A GitHub action for application version bump, generation, reading and format in release pipelines","archived":false,"fork":false,"pushed_at":"2025-03-12T03:25:49.000Z","size":1506,"stargazers_count":24,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-03-12T04:24:15.864Z","etag":null,"topics":["actions","bump","bump-version","bumping","bumpversion","generate","github","prerelease","release","release-automation","release-pipelines","version","versioning"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HardNorth.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-25T06:02:20.000Z","updated_at":"2025-03-12T03:24:49.000Z","dependencies_parsed_at":"2023-02-08T10:01:49.278Z","dependency_job_id":"6603544f-2c59-44d3-85eb-c24d5ddd1783","html_url":"https://github.com/HardNorth/github-version-generate","commit_stats":{"total_commits":180,"total_committers":3,"mean_commits":60.0,"dds":0.1611111111111111,"last_synced_commit":"f23a655418502fc2d2f4138a57b34e0d27bc6f1a"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HardNorth%2Fgithub-version-generate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HardNorth%2Fgithub-version-generate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HardNorth%2Fgithub-version-generate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HardNorth%2Fgithub-version-generate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HardNorth","download_url":"https://codeload.github.com/HardNorth/github-version-generate/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243809844,"owners_count":20351406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","bump","bump-version","bumping","bumpversion","generate","github","prerelease","release","release-automation","release-pipelines","version","versioning"],"created_at":"2024-10-09T23:49:28.305Z","updated_at":"2025-03-16T09:33:15.872Z","avatar_url":"https://github.com/HardNorth.png","language":"JavaScript","readme":"# Version generation and bumping for GitHub Actions\n\n[![CI Build](https://github.com/HardNorth/github-version-generate/actions/workflows/ci.yml/badge.svg)](https://github.com/HardNorth/github-version-generate/actions/workflows/ci.yml)\n[![License](https://img.shields.io/badge/License-Apache%202.0-brightgreen.svg)](https://opensource.org/licenses/Apache-2.0)\n\n\u003e Please star this repository if you like the application, it will help more people see it. Thank you!\n\nA GitHub action for reading, bumping, generating, formatting applications versions in release pipelines.\nOutputs four environment / output variables:\n\n- 'env.CURRENT_VERSION' - a current, extracted version of application without any changes\n- 'env.RELEASE_VERSION' - a generated release version with `SNAPSHOT` suffix removed by default\n- 'env.NEXT_VERSION' - a new version supposed to put into version source file instead of CURRENT_VERSION\n- 'env.NEXT_RELEASE_VERSION' - the same new version with `SNAPSHOT` suffix removed by default\n\nAlso, there are 5 postfixes for environment variables listed above:\n\n- '_MAJOR'\n- '_MINOR'\n- '_PATCH'\n- '_PRERELEASE'\n- '_BUILDMETADATA'\n\nThey contain corresponding version fragments, so for release version `5.0.3` environment / output variable\n`RELEASE_VERSION_PATCH` will contain `3`.\n\nThe action uses so-called \"[Semantic version](https://semver.org/)\" system, please check out the\nspecification first to avoid misunderstanding and misuses.\n\nBy default, the action increments prerelease version. Basically it picks a number in a substring starting with\nalpha|beta|rc + a number. It also possible to notate all caps or starting with a capital letter (ALPHA, alpha and Alpha\nare OK).\n\nE.G.:\n\n- TESTNG7-BETA-7-SNAPSHOT \u0026rarr; TESTNG7-BETA-8-SNAPSHOT\n- rc1 \u0026rarr; rc2\n- TESTNG6-Alpha1 \u0026rarr; Alpha2\n\nHere are some prerelease fragments and a regex which is used to extract the prerelease number:\nhttps://regex101.com/r/O5GUdN/2\n\nIf there is no regex match in prerelease section the patch version fragment will be incremented. You\ncan force action increment a specific version fragment you like by configuring [Next version](#next-version) parameters.\nIf any of such parameters was specified the default behavior will be ignored.\n\n## Usage\n\nTo use the action introduce it into your job steps of a github actions workflow.\n\n### Example 1: Java application built with gradle\n\nA pretty simple pipeline which launches a release task. To update development version back in a release branch Gradle\nrelease plugin needs at least one parameter specified (`release.newVersion`). This pipeline provides gradle both\nnecessary versions: which to release and which to commit back into the release branch.\n\n```yaml\nname: Release\n\non:\n  push:\n    branches:\n      - 'master'\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v3\n\n      - name: Set up JDK 1.8\n        uses: actions/setup-java@v3\n        with:\n          distribution: 'temurin'\n          java-version: '8'\n\n      - name: Generate versions\n        uses: HardNorth/github-version-generate@v1.4.0\n        with:\n          version-source: file\n          version-file: gradle.properties\n          version-file-extraction-pattern: '(?\u003c=version=).+'\n\n      - name: Grant execute permission for gradlew\n        run: chmod +x gradlew\n\n      - name: Release with Gradle\n        id: release\n        run: |\n          ./gradlew release -Prelease.useAutomaticVersion=true \\\n          -Prelease.releaseVersion=${{ env.RELEASE_VERSION }} \\\n          -Prelease.newVersion=${{ env.NEXT_VERSION }}\n```\n\n### Example 2: A specific version fragment incrementation\n\nThe pipeline demonstrates how you can control which version fragment to increment by a file with a specific keyword:\n\n```yaml\nname: release\n\non:\n  push:\n    branches:\n      - master\n\nenv:\n  VERSION_FILE_NAME: 'VERSION'\n  VERSION_BUMP_FILE: 'version_fragment'\njobs:\n  calculate-version:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v3\n\n      - name: Get version fragment to bump\n        id: getVersionFragment\n        run: |\n          read -r versionFragment \u003c ${{ env.VERSION_BUMP_FILE }}\n          echo \"'$versionFragment' version will be incremented\"\n          echo \"::set-env name=VERSION_FRAGMENT::${versionFragment}\"\n\n      - name: Generate versions\n        uses: HardNorth/github-version-generate@v1.4.0\n        with:\n          version-source: file\n          version-file: ${{ env.VERSION_FILE_NAME }}\n          next-version-increment-patch: ${{ contains(env.VERSION_FRAGMENT, 'patch') }}\n          next-version-increment-minor: ${{ contains(env.VERSION_FRAGMENT, 'minor') }}\n          next-version-increment-major: ${{ contains(env.VERSION_FRAGMENT, 'major') }}\n```\n\nIf the content of the `version_fragment` file will be \"minor\" then minor version will be incremented respectively.\n\n## Configuration\n\n### Version sources\n\n| Parameter                       | Type                 | Default value | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n|---------------------------------|----------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| version-source                  | enum{file, variable} | variable      | A source of a CURRENT_VERSION                                                                                                                                                                                                                                                                                                                                                                                                                                                 |\n| version                         | string               |               | A version variable for version source                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| version-file                    | string               |               | A path to a file which holds a version                                                                                                                                                                                                                                                                                                                                                                                                                                        |\n| version-file-extraction-pattern | string               | .+            | A RegEx to extract version from a version-source file. Should either match a full version, or return it as the first group. E.G: \u003cbr /\u003e\u003cul\u003e\u003cli\u003e`(?\u003c=version=).+` - pattern match, e.g: 'version=5.0.3-SNAPSHOT' will extract matched string '5.0.3-SNAPSHOT'\u003c/li\u003e\u003cli\u003e`\"version\":\\s*\"([^\"]+)\"` - group match, will extract the first group. e.g: '\"version\": \"1.0.0\",' to '1.0.0'\u003c/li\u003e\u003c/ul\u003eIn case if there are several groups in a pattern the first group will be extracted. |\n\n### Release version\n\n| Parameter                               | Type    | Default value       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |\n|-----------------------------------------|---------|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| release-version-cut-snapshot            | boolean | true                | Remove \"SNAPSHOT\" suffix from source version                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| release-version-cut-build-metadata      | boolean | true                | Remove build metadata suffix from source version                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| release-version-cut-prerelease          | boolean | false               | Remove prerelease part from source version                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |\n| release-version-generate-build-metadata | boolean | false               | Put build metadata (release date, commit sha, etc.) into result RELEASE_VERSION                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |\n| release-version-build-metadata-pattern  | string  | build.{date}.{hash} | Format pattern for build metadata. EG: `build.{date[YYYY-MM-dd]}.{hash[0, 6]}`. It is also possible not to customize variable outputs omitting square braces ([]) or even not to use any variables. Supported variables: \u003cbr/\u003e\u003cul\u003e\u003cli\u003e`date[date_format]`: a current date in UTC or time set in 'release-version-build-metadata-datetime' variable. Supports formatting included in square braces ([]). The date format will be applied by \"Moment.js\". Default format is `['YYYY-MM-DD']`.\u003cbr /\u003eLibrary: https://momentjs.com/ \u003c/li\u003e\u003cli\u003e`hash[begin_index_inclusive, end_index_exclusive]`: a commit hash, which triggered this build. You can shorten the hash by specifying begin and end characters indexes included in square braces ([]), separated by a comma. Default begin, end values are: `[0, 8]`. |\n| release-version-build-metadata-datetime | string  |                     | A time stamp in ISO format to put into a build metadata string, by default the action uses current time in UTC timezone                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |\n\n### Next version\n\n| Parameter                         | Type    | Default value | Description                                                                                                                                                 |\n|-----------------------------------|---------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| next-version-increment-major      | boolean | false         | Increment major version in result NEXT_VERSION, resets all other versions to \"0\" and prerelease to \"1\" if found. E.G.: `5.0.3-BETA-3` \u0026rarr; `6.0.0-BETA-1` |\n| next-version-increment-minor      | boolean | false         | Increment minor version in result NEXT_VERSION, resets patch to \"0\" and prerelease to \"1\" if found. E.G.: `5.0.3-BETA-3` \u0026rarr; `5.1.0-BETA-1`              |\n| next-version-increment-patch      | boolean | false         | Increment patch version in result NEXT_VERSION, resets prerelease to \"1\" if found. E.G.: `5.0.3-BETA-3` \u0026rarr; `5.0.4-BETA-1`                               |\n| next-version-increment-prerelease | boolean | false         | Increment prerelease version in result NEXT_VERSION. E.G.: `5.0.3-BETA-3` \u0026rarr; `5.0.3-BETA-4`                                                             |\n| next-version-cut-prerelease       | boolean | false         | Remove prerelease part from source version. In case this parameter is set the action increments patch version by default.                                   |\n| next-version-cut-build-metadata   | boolean | true          | Remove build metadata suffix from source version                                                                                                            |\n| next-version-put-build-metadata   | boolean | false         | Put build metadata (release date, commit sha, etc.) into result NEXT_VERSION. Will be the same as for RELEASE_VERSION'                                      |\n\n### Data extract\n\nBuilt-in data extraction mechanism.\n\nExample:\n\n```yaml\ndata-extract: true\ndata-extract-name: 'first_variable'\ndata-extract-paths: '/path/to/file'\ndata-extract-patterns: '/(?\u003c=variable.name=).+/i'\n```\n\nThere are several use cases depending on RegEx format and flags:\n\n* RegEx Match only - As on example, above. Variable name in 'data-extract-name' parameter will be used 'as is',\n  variable value will be set on matched text. Extraction will fail if 'data-extract-name' is not set.\n* One group - Variable name in 'data-extract-name' parameter will be used 'as is', variable value will be set on\n  group value. Extraction will fail if 'data-extract-name' is not set.\n* Two or more groups - If 'data-extract-name' value is set then the first group will be used as value, and other\n  groups will be ignored, if it's not set, then the first group will used as variable name and the second group\n  will be used as value.\n* Multiple match (multiple RegEx, 'g' flag in RegEx is set, etc) - If 'data-extract-name' value is set the action\n  will extract all RegEx matches and export variables with underscore and variable index as suffix, except the\n  first one.\n  E.G.: first_variable -\u003e FIRST_VARIABLE, FIRST_VARIABLE_1, etc; If 'data-extract-name' value is not set then\n  two groups in every RegEx is a requirement, the first group will used as variable name and the second group will\n  be used as value. If multiple files have the same variable names, output values will be overwritten with the\n  latter matches.\n\nVariable name convert rules:\n\n* Spaces and symbols '-', even multiple in a row, will be converted to single symbol '_';\n* Other special characters except digits and letters will be cut off;\n* The variable name will be converted to upper case.\n\n| Parameter                       | Type    | Default value | Description                                                                                                                                                                                                 |\n|---------------------------------|---------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| data-extract                    | boolean | false         | Enable data extraction mechanism                                                                                                                                                                            |\n| data-extract-name               | string  | null          | Variable name to which extracted data will be placed, standard variable name conversion rules are also applied to this field. If not set it will be extracted from RegEx groups. See usage use cases above. |\n| data-extract-paths              | string  | null          | Semicolon (\";\") separated path list of files which to use to extract data                                                                                                                                   |\n| data-extract-patterns           | string  | null          | Semicolon (\";\") separated RegEx pattern list wrapped with \"/\" symbols, with flags                                                                                                                           |\n\n### Real-life examples\n\n- The action builds using itself, check\n  out [Release](https://github.com/HardNorth/github-version-generate/blob/master/.github/workflows/release.yml)\n  pipeline.\n- [Report Portal](https://reportportal.io/) uses the action to build its agents.\n  E.G.: [JUnit](https://github.com/reportportal/agent-java-junit/blob/master/.github/workflows/release.yml)\n\n### License\n\nApache License Version 2.0 - [repo link](https://github.com/HardNorth/github-version-generate/blob/master/LICENSE).\n\n### Credits\n\nThe action was created by [Vadzim Hushchanskou](https://github.com/HardNorth)\nat [HardNorth/github-version-generate](https://github.com/HardNorth/github-version-generate)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardnorth%2Fgithub-version-generate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhardnorth%2Fgithub-version-generate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardnorth%2Fgithub-version-generate/lists"}