diff --git a/.github/actions/semantic/action.yaml b/.github/actions/semantic/action.yaml new file mode 100644 index 0000000..4f58b42 --- /dev/null +++ b/.github/actions/semantic/action.yaml @@ -0,0 +1,49 @@ +name: "Test job" +description: "Reusable action to perform a task" +inputs: + github-token: + description: "GitHub token for the semantic release action" + required: true + release-assets: + required: false + type: string + default: '' + tag-prefix: + description: "Tag prefix for the release" + required: false + type: string + default: 'v' +runs: + using: "composite" + steps: + - name: Checkout + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + + - name: Semantic Release + id: semantic + uses: cycjimmy/semantic-release-action@8e58d20d0f6c8773181f43eb74d6a05e3099571d # v3.4.2 + with: + extra_plugins: | + @semantic-release/changelog + @semantic-release/git + branches: | + [ + 'master', + 'main' + ] + tag_format: ${{ inputs.tag-prefix }}${version} + env: + GITHUB_TOKEN: ${{ inputs.github-token }} + + - name: Semantic Release - Output + shell: bash + run: | + echo "### Semantic Release published: ${{ steps.semantic.outputs.new_release_published }}" >> $GITHUB_STEP_SUMMARY + echo "### Semantic Release version: ${{ steps.semantic.outputs.new_release_version }}" >> $GITHUB_STEP_SUMMARY + + - name: Upload Additional Assets + if: inputs.release-assets != '' && steps.semantic.outputs.new_release_published == 'true' + uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1 + with: + tag_name: ${{ inputs.tag-prefix }}${{ steps.semantic.outputs.new_release_version }} + files: ${{ inputs.release-assets }} diff --git a/.github/workflows/pr-semantic.yaml b/.github/workflows/pr-semantic.yaml index b122a4e..395f28e 100644 --- a/.github/workflows/pr-semantic.yaml +++ b/.github/workflows/pr-semantic.yaml @@ -9,10 +9,21 @@ on: jobs: semantic-release: - uses: ./.github/workflows/reusable-semantic.yaml - with: - environment: dev - release-assets: | - gradle/wrapper/gradle-wrapper.properties - build.gradle - tag-prefix: 'test-v' \ No newline at end of file + runs-on: ubuntu-22.04 + environment: ${{ inputs.environment }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Create + run: echo "TEST" >> test.txt + + - name: Create + uses: ./.github/actions/semantic + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + release-assets: | + gradle/wrapper/gradle-wrapper.properties + build.gradle + text.txt + tag-prefix: 'test-v' \ No newline at end of file diff --git a/.github/workflows/reusable-semantic.yaml b/.github/workflows/reusable-semantic.yaml deleted file mode 100644 index 76834ca..0000000 --- a/.github/workflows/reusable-semantic.yaml +++ /dev/null @@ -1,53 +0,0 @@ -name: "Test job" - -on: - workflow_call: - inputs: - environment: - required: true - type: string - release-assets: - required: false - type: string - default: '' - tag-prefix: - description: "Tag prefix for the release" - required: false - type: string - default: 'v' -jobs: - semantic-release: - runs-on: ubuntu-22.04 - environment: ${{ inputs.environment }} - steps: - - name: Checkout - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - - - name: Semantic Release - id: semantic - uses: cycjimmy/semantic-release-action@8e58d20d0f6c8773181f43eb74d6a05e3099571d # v3.4.2 - with: - extra_plugins: | - @semantic-release/changelog - @semantic-release/git - branches: | - [ - 'master', - 'main' - ] - tag_format: ${{ inputs.tag-prefix }}${version} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Semantic Release - Output - shell: bash - run: | - echo "### Semantic Release published: ${{ steps.semantic.outputs.new_release_published }}" >> $GITHUB_STEP_SUMMARY - echo "### Semantic Release version: ${{ steps.semantic.outputs.new_release_version }}" >> $GITHUB_STEP_SUMMARY - - - name: Upload Additional Assets - if: inputs.release-assets != '' && steps.semantic.outputs.new_release_published == 'true' - uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1 - with: - tag_name: ${{ inputs.tag-prefix }}${{ steps.semantic.outputs.new_release_version }} - files: ${{ inputs.release-assets }} \ No newline at end of file