From 9eb60c1d465b01aefb9c663834b95aa03ce2464d Mon Sep 17 00:00:00 2001 From: vscaiceanu-1a <86055112+vscaiceanu-1a@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:39:58 +0200 Subject: [PATCH] feat(github-action): create GitHub Release Action --- .github/workflows/main.yml | 5 ++++- tools/github-actions/README.md | 1 + tools/github-actions/release/LICENSE | 26 +++++++++++++++++++++++++ tools/github-actions/release/action.yml | 15 ++++++++++++++ tools/github-actions/release/readme.md | 23 ++++++++++++++++++++++ 5 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tools/github-actions/release/LICENSE create mode 100644 tools/github-actions/release/action.yml create mode 100644 tools/github-actions/release/readme.md diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f4f4ceb8b2..15f9571227 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -72,7 +72,10 @@ jobs: releaseBranchRegExp: 'release\/(0|[1-9]\d*)\.(0|[1-9]\d*)(\.0-(?:next|prerelease|rc))?$' - name: Create release if: github.event_name != 'pull_request' && github.event_name != 'merge_group' - run: gh release create v${{ steps.newVersion.outputs.nextVersionTag }} --generate-notes ${{ contains( steps.newVersion.outputs.nextVersionTag, '-' ) && '--prerelease' || '' }} --target ${{ github.ref_name }} + uses: ./tools/github-actions/release + with: + version: ${{ steps.newVersion.outputs.nextVersionTag }} + target: ${{ github.ref_name }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/tools/github-actions/README.md b/tools/github-actions/README.md index fe856bfe74..0a84b18821 100644 --- a/tools/github-actions/README.md +++ b/tools/github-actions/README.md @@ -8,3 +8,4 @@ Actions currently available : * Setup action [Documentation](setup/readme.md) * Upload build output action [Documentation](upload-build-output/readme.md) * Download build output action [Documentation](download-build-output/readme.md) +* New GitHub Release action [Documentation](release/readme.md) diff --git a/tools/github-actions/release/LICENSE b/tools/github-actions/release/LICENSE new file mode 100644 index 0000000000..10ae923f74 --- /dev/null +++ b/tools/github-actions/release/LICENSE @@ -0,0 +1,26 @@ +Copyright Amadeus SAS + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tools/github-actions/release/action.yml b/tools/github-actions/release/action.yml new file mode 100644 index 0000000000..40c9a4824a --- /dev/null +++ b/tools/github-actions/release/action.yml @@ -0,0 +1,15 @@ +name: Create a new GitHub Release +description: Creates a new GitHub Release for a given version +inputs: + version: + description: 'The version to create the release for' + required: true + target: + description: 'The branch to target' + required: true +runs: + using: "composite" + steps: + - name: Create release + shell: bash + run: gh release create v${{ inputs.version }} --generate-notes ${{ contains( inputs.version, '-' ) && '--prerelease' || '' }} --target ${{ inputs.target }} diff --git a/tools/github-actions/release/readme.md b/tools/github-actions/release/readme.md new file mode 100644 index 0000000000..a0bb956a44 --- /dev/null +++ b/tools/github-actions/release/readme.md @@ -0,0 +1,23 @@ +# Create a new Github Release + +## Overview + +GitHub Action for creating a new release on GitHub. + +> [!NOTE] +> This action requires `contents: write` [permission](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token) in order to create the release. + +## Task options + +See [Action specifications](./action.yml) directly for more information about the supported parameters. + +## Usage example + +```yaml +- name: Create release + if: github.event_name != 'pull_request' + uses: AmadeusITGroup/otter/tools/github-actions/release + with: + version: ${{ nextVersionTag }} + target: ${{ github.ref_name }} +```