|
| 1 | +name: Update Major Release |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: |
| 6 | + - published |
| 7 | + |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + TAG_NAME: |
| 11 | + description: "Tag name that the major tag will point to" |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + |
| 15 | + workflow_call: |
| 16 | + inputs: |
| 17 | + TAG_NAME: |
| 18 | + description: "Tag name that the major tag will point to" |
| 19 | + required: true |
| 20 | + type: string |
| 21 | + |
| 22 | +env: |
| 23 | + TAG_NAME: ${{ github.event.release.tag_name || inputs.TAG_NAME }} |
| 24 | + |
| 25 | +jobs: |
| 26 | + update_major_tag: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + name: Update Major Tag |
| 29 | + environment: major-release-update |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@v2 |
| 33 | + |
| 34 | + - name: Get major release version |
| 35 | + id: get-major-version |
| 36 | + run: | |
| 37 | + echo "Tag name: ${TAG_NAME}" |
| 38 | + major_version=${TAG_NAME%.*.*} |
| 39 | + echo "Major Version: ${major_version}" |
| 40 | + echo "::set-output name=major_version::$major_version" |
| 41 | +
|
| 42 | + - name: Check if major version exists |
| 43 | + id: check-release |
| 44 | + run: | |
| 45 | + .github/scripts/check-release.sh \ |
| 46 | + ${{ github.repository }} \ |
| 47 | + ${{ steps.get-major-version.outputs.major_version }} \ |
| 48 | + ${{ secrets.GITHUB_TOKEN }} |
| 49 | +
|
| 50 | + - name: Get Source Tag SHA |
| 51 | + id: source-tag-sha |
| 52 | + run: | |
| 53 | + .github/scripts/source-tag-sha.sh \ |
| 54 | + ${{ github.repository }} \ |
| 55 | + ${TAG_NAME} \ |
| 56 | + ${{ secrets.GITHUB_TOKEN }} |
| 57 | +
|
| 58 | + - name: Create Major Release |
| 59 | + uses: softprops/action-gh-release@v1 |
| 60 | + if: steps.check-release.outputs.release_exists == 'false' |
| 61 | + id: create_release |
| 62 | + with: |
| 63 | + name: ${{ steps.get-major-version.outputs.major_version }} |
| 64 | + tag_name: ${{ steps.get-major-version.outputs.major_version }} |
| 65 | + target_commitish: ${{ steps.source-tag-sha.outputs.sha }} |
| 66 | + |
| 67 | + - name: Update Major tag |
| 68 | + if: steps.check-release.outputs.release_exists == 'true' |
| 69 | + run: | |
| 70 | + .github/scripts/update-major-tag.sh \ |
| 71 | + ${{ github.repository }} \ |
| 72 | + ${{ steps.source-tag-sha.outputs.sha }} \ |
| 73 | + ${{ steps.get-major-version.outputs.major_version }} \ |
| 74 | + ${{ secrets.GITHUB_TOKEN }} |
0 commit comments