From 4073cac8a92f87698b3423d2e2c299e0beeb3447 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Fri, 20 Oct 2023 21:33:30 -0400 Subject: [PATCH] feat: initial version --- .github/workflows/ci.yml | 59 ++++++++++++++++++++++++++++++++++++++++ .gitignore | 2 ++ README.md | 5 ++-- action.yml | 56 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 action.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b257971 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,59 @@ +--- +name: CI + +on: + pull_request: + branches: [master] + types: [opened, synchronize, reopened] + push: + branches: [master] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + action: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Release + id: setup-release + uses: LizardByte/setup-release-action@master + with: + changelog_path: ./tests/data/set${{ matrix.set }}/CHANGELOG.md + fail_on_events_api_error: false + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set PR tag + id: pr-tag + if: ${{ github.event_name == 'pull_request' }} + run: | + echo "release_tag=pr-${{ github.run_id }}" >> $GITHUB_OUTPUT + + - name: Run Action + id: action + uses: ./ + with: + allowUpdates: false + artifacts: '' + body: '' + discussionCategory: ${{ github.event_name == 'pull_request' && 'tests' || 'announcements' }} + generateReleaseNotes: true + name: ${{ steps.setup-release.outputs.release_tag }} + prerelease: ${{ steps.setup-release.outputs.publish_stable_release != 'True' }} + tag: >- + ${{ github.event_name == 'pull_request' && steps.pr-tag.outputs.release_tag || + steps.setup-release.outputs.release_tag }} + token: ${{ github.event_name == 'pull_request' && secrets.GITHUB_TOKEN || secrets.GH_BOT_TOKEN}} + +# - name: Delete Release +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# if: ${{ github.event_name == 'pull_request' }} +# uses: dev-drprasad/delete-tag-and-release@v0.2.1 +# with: +# tag_name: ${{ steps.pr-tag.outputs.release_tag }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..225ce7e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# ignore jetbrains files +.idea/ diff --git a/README.md b/README.md index fd3e658..98daf7b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ -# template-base -Base repository template for LizardByte. +# create-release-action +A reusable action to create a GitHub release. This action is tailored to the +@LizardByte organization, but can be used by anyone if they follow the same conventions. diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..4425603 --- /dev/null +++ b/action.yml @@ -0,0 +1,56 @@ +--- +name: "Create Release" +description: "A reusable action to create a GitHub release." +author: "LizardByte" +inputs: + allowUpdates: + description: 'An optional flag which indicates if we should update a release if it already exists.' + required: false + default: 'true' + artifacts: + description: 'The artifacts to upload.' + required: true + default: '*artifacts/*' + body: + description: 'The body of the release.' + required: true + discussionCategory: + description: 'The category of the discussion.' + required: false + default: 'announcements' + generateReleaseNotes: + description: 'Indicates if release notes should be automatically generated.' + required: false + default: 'false' + name: + description: 'The version to create.' + required: true + prerelease: + description: 'Whether the release is a prerelease.' + required: false + default: 'false' + tag: + description: 'The tag to create.' + required: true + token: + description: 'Github Token.' + required: true + +runs: + using: "composite" + steps: + - name: Create/Update GitHub Release + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + uses: ncipollo/release-action@v1.13.0 + with: + allowUpdates: ${{ inputs.allowUpdates }} + artifactErrorsFailBuild: true + artifacts: ${{ inputs.artifacts }} + body: ${{ inputs.body }} + commit: ${{ github.sha }} + discussionCategory: ${{ inputs.discussionCategory }} + generateReleaseNotes: ${{ inputs.generateReleaseNotes }} + name: ${{ inputs.name }} + prerelease: ${{ inputs.prerelease }} + tag: ${{ inputs.tag }} + token: ${{ inputs.github_token }}