diff --git a/.github/workflows/main-workflow.yml b/.github/workflows/main-workflow.yml index bacf274..f06918b 100644 --- a/.github/workflows/main-workflow.yml +++ b/.github/workflows/main-workflow.yml @@ -1,4 +1,4 @@ -name: Main Workflow +name: Create new tag and release on push to jitpack-cd branch on: push: @@ -9,18 +9,46 @@ permissions: contents: write jobs: - independent-job: + create-new-tag-and-release: runs-on: ubuntu-latest + steps: - name: Checkout repository uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Print message - run: echo "This is an independent job" - handle-new-tag: - uses: ./.github/workflows/new-tag.yml + - name: Get next version + id: get_next_version + uses: thenativeweb/get-next-version@2.6.2 + + - name: Check for existing tag + id: check_tag + run: | + if git rev-parse "refs/tags/${{ steps.get_next_version.outputs.version }}" >/dev/null 2>&1; then + echo "Tag already exists" + exit 1 + fi + + - name: Push new tag + if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' && steps.check_tag.outcome != 'failure' }} + run: | + git tag ${{ steps.get_next_version.outputs.version }} + git push origin ${{ steps.get_next_version.outputs.version }} - handle-new-release: - uses: ./.github/workflows/new-release.yml \ No newline at end of file + - name: Read release body from file + id: read_release_body + run: | + echo "RELEASE_BODY=$(cat release-notes.txt)" >> $GITHUB_ENV + + - name: Create GitHub Release + if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' && steps.check_tag.outcome != 'failure' }} + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.get_next_version.outputs.version }} + release_name: 'Auto OTP Reader ${{ steps.get_next_version.outputs.version }}' + body: ${{ env.RELEASE_BODY }} + draft: false + prerelease: false \ No newline at end of file diff --git a/.github/workflows/new-release.yml b/.github/workflows/new-release.yml deleted file mode 100644 index b3129cd..0000000 --- a/.github/workflows/new-release.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Handle new release - -on: - workflow_call: - -permissions: - contents: write - -jobs: - create-new-release: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Read release body from file - id: read_release_body - run: | - echo "RELEASE_BODY=$(cat release-notes.txt)" >> $GITHUB_ENV - - - name: Check hasNextVersion - run: | - if [ "${{ needs.handle-new-tag.outputs.hasNextVersion }}" == "true" ]; then - echo "There is a next version" - else - echo "There is no next version" - fi - - - name: Create GitHub Release - if: ${{ needs.handle-new-tag.outputs.hasNextVersion == 'true' && steps.check_tag.outcome != 'failure' }} - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.get_next_version.outputs.version }} - release_name: 'Auto OTP Reader ${{ steps.get_next_version.outputs.version }}' - body: ${{ env.RELEASE_BODY }} - draft: false - prerelease: false \ No newline at end of file diff --git a/.github/workflows/new-tag.yml b/.github/workflows/new-tag.yml deleted file mode 100644 index 95c971c..0000000 --- a/.github/workflows/new-tag.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Handle new tag - -on: - workflow_call: - -permissions: - contents: write - -jobs: - create-new-tag: - runs-on: ubuntu-latest - - outputs: - hasNextVersion: ${{ steps.get_next_version.outputs.hasNextVersion }} - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Get next version - id: get_next_version - uses: thenativeweb/get-next-version@2.6.2 - - - name: Check for existing tag - id: check_tag - run: | - if git rev-parse "refs/tags/${{ steps.get_next_version.outputs.version }}" >/dev/null 2>&1; then - echo "Tag already exists" - exit 1 - fi - - - name: Push new tag - if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' && steps.check_tag.outcome != 'failure' }} - run: | - git tag ${{ steps.get_next_version.outputs.version }} - git push origin ${{ steps.get_next_version.outputs.version }} \ No newline at end of file