├── .editorconfig ├── .github └── workflows │ ├── create-new-pre-release.yml │ └── release-new-action-version.yml ├── LICENSE ├── README.md ├── VERSION ├── action.yml └── setup-jira-automation-rule.png /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | 15 | [VERSION] 16 | insert_final_newline = false 17 | -------------------------------------------------------------------------------- /.github/workflows/create-new-pre-release.yml: -------------------------------------------------------------------------------- 1 | name: Create new pre-release 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | workflow_dispatch: 8 | 9 | env: 10 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 11 | 12 | defaults: 13 | run: 14 | shell: bash 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@v4 22 | 23 | - name: Set build version number 24 | run: | 25 | echo VERSION=$(cat VERSION).$GITHUB_RUN_NUMBER >> $GITHUB_ENV 26 | 27 | - name: Create GitHub pre-release 28 | run: | 29 | gh api \ 30 | --method POST \ 31 | --header "Accept: application/vnd.github+json" \ 32 | /repos/${GITHUB_REPOSITORY}/releases \ 33 | -f tag_name='v${{ env.VERSION }}' \ 34 | -f target_commitish='main' \ 35 | -f name='${{ env.VERSION }}' \ 36 | -F prerelease=true \ 37 | -------------------------------------------------------------------------------- /.github/workflows/release-new-action-version.yml: -------------------------------------------------------------------------------- 1 | name: Release new action version 2 | 3 | on: 4 | release: 5 | types: [released] 6 | workflow_dispatch: 7 | inputs: 8 | TAG_NAME: 9 | description: 'Tag name that the major tag will point to' 10 | required: true 11 | 12 | env: 13 | TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} 14 | permissions: 15 | contents: write 16 | 17 | jobs: 18 | update_tag: 19 | name: Update the major tag to include the ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} changes 20 | environment: 21 | name: releaseNewActionVersion 22 | runs-on: ubuntu-latest 23 | steps: 24 | - name: Update the ${{ env.TAG_NAME }} tag 25 | id: update-major-tag 26 | uses: actions/publish-action@v0.3.0 27 | with: 28 | source-tag: ${{ env.TAG_NAME }} 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 GeoWerkstatt GmbH 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # create-jira-release (GitHub Action) 2 | 3 | [![Release](https://github.com/GeoWerkstatt/create-jira-release/actions/workflows/release-new-action-version.yml/badge.svg)](https://github.com/GeoWerkstatt/create-jira-release/actions/workflows/release-new-action-version.yml) 4 | 5 | Creates a new Jira release for a specific Jira project and assigns all relevant* Jira issue numbers to it. 6 | \* All Jira issue numbers (e.g. TEST-123) in commit messages since last Git tag. 7 | 8 | ## Prerequisites 9 | 10 | In order to be able to use this GitHub Action, a custom Jira automation rule needs to be created first. Please refer to the screenshot below for the most important settings. 11 | 12 | ![Setup Jira automation rule](./setup-jira-automation-rule.png) 13 | 14 | ## Usage 15 | 16 | See [action.yml](action.yml) 17 | 18 | ```yaml 19 | steps: 20 | - uses: actions/checkout@v4 21 | 22 | - uses: GeoWerkstatt/create-jira-release@v1 23 | with: 24 | jira-project-key: 'TEST' 25 | jira-automation-webhook: ${{ secrets.JIRA_AUTOMATION_WEBHOOK }} 26 | build-version: v${{ env.VERSION }} 27 | ``` 28 | 29 | ## Options 30 | 31 | | key | description | required | 32 | | ------------------------- | ------------------------------------- | -------- | 33 | | `jira-project-key` | Jira project identifier (e.g. _TEST_) | true | 34 | | `jira-automation-webhook` | Jira automation webhook url | true | 35 | | `build-version` | Version identifier | true | 36 | 37 | ## Secrets 38 | 39 | | key | description | required | 40 | | --------------------------------- | ------------------------------------------------------------------------------------------------------------------- | -------- | 41 | | `secrets.JIRA_AUTOMATION_WEBHOOK` | Can be obtained or regenerated in the _Incoming webhook_ automation step of the corresponding Jira automation rule. | true | 42 | 43 | ## Publish new GitHub Action version 44 | 45 | A new GitHub _pre-release_ is created [automatically](./.github/workflows/create-new-pre-release.yml) if there are new changes on the `main` branch. Uncheck _This is a pre-release_ in the _Edit_-Section for a specific pre-release in order to [update](./.github/workflows/release-new-action-version.yml) a major tag (e.g. v1) to point to the latest release. A major tag from the latest released tag is created automatically if a corresponding major tag doesn't exist already. 46 | 47 | ## License 48 | 49 | The scripts and documentation in this project are released under the [MIT License](LICENSE) 50 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.0 -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "Jira Release Web Hook" 2 | description: "Creates a new Jira release and assigns all relevant issues to it." 3 | inputs: 4 | jira-project-key: 5 | description: "Jira project identifier" 6 | required: true 7 | jira-automation-webhook: 8 | description: "Jira automation webhook url" 9 | required: true 10 | build-version: 11 | description: "Version identifier" 12 | required: true 13 | runs: 14 | using: "composite" 15 | steps: 16 | - name: Fetch entire Git history (including tags) 17 | run: | 18 | [ "$(git rev-parse --is-shallow-repository)" = "true" ] && \ 19 | git fetch --prune --unshallow --tags || \ 20 | git fetch --prune --tags 21 | shell: bash 22 | 23 | - name: Collect issue numbers since last release/tag 24 | run: | 25 | export LC_ALL=en_US.utf8 26 | git log $(git describe --abbrev=0 --tags 2> /dev/null || git rev-list --max-parents=0 HEAD)..HEAD | \ 27 | grep -oE "${{ inputs.jira-project-key }}-[[:digit:]]{1,}" | sort | uniq | \ 28 | sed 's/^\|$/"/g' | paste -sd , - | awk '{print "RELATED_JIRA_ISSUES="$0}' >> $GITHUB_ENV 29 | shell: bash 30 | 31 | - name: Create json and invoke webhook 32 | run: | 33 | $json = ConvertTo-Json @{issues = @(${{ env.RELATED_JIRA_ISSUES }}); data = @{version = "${{ inputs.build-version }}"; projectName = "${{ inputs.jira-project-key }}"}} 34 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 35 | Invoke-RestMethod ${{ inputs.jira-automation-webhook }} -Method Post -Body $json -ContentType "application/json" 36 | shell: pwsh 37 | -------------------------------------------------------------------------------- /setup-jira-automation-rule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeoWerkstatt/create-jira-release/66a6a3a84ddaf7349c47ee0aa20f252b80420146/setup-jira-automation-rule.png --------------------------------------------------------------------------------