|
1 | 1 | # Summary: |
2 | 2 | # Automatically tag and release when changes land on the "main" branch. |
| 3 | +# It uses "semantic-version" to resolve the next version to use, and then we use GitHub CLI to create or update the releases. |
3 | 4 | # |
4 | 5 | # See https://github.com/PaulHatch/semantic-version https://github.com/PaulHatch/semantic-version/tree/v5.0.2 |
5 | 6 | # See https://github.com/softprops/action-gh-release https://github.com/softprops/action-gh-release/tree/v1 |
@@ -50,28 +51,74 @@ jobs: |
50 | 51 | echo "current_commit: ${{steps.next_semantic_version.outputs.current_commit}}" |
51 | 52 |
|
52 | 53 | - name: Creating Git release tag for the "${{steps.next_semantic_version.outputs.version_tag}}" version |
53 | | - uses: ncipollo/release-action@v1 |
54 | | - with: # See https://github.com/softprops/action-gh-release#-customizing |
55 | | - token: "${{ secrets.GITHUB_TOKEN }}" |
56 | | - tag: ${{steps.next_semantic_version.outputs.version_tag}} |
57 | | - name: "Automatic release ${{steps.next_semantic_version.outputs.version_tag}}" |
58 | | - makeLatest: true |
59 | | - allowUpdates: false |
60 | | - prerelease: false |
61 | | - generateReleaseNotes: true |
62 | | - artifacts: | |
63 | | - CHANGELOG.md |
| 54 | + run: | |
| 55 | + gh release create v${{steps.next_semantic_version.outputs.version_tag}} \ |
| 56 | + --title "v${{steps.next_semantic_version.outputs.version_tag}}" \ |
| 57 | + --generate-notes \ |
| 58 | + --target $GITHUB_SHA |
| 59 | + env: |
| 60 | + GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
64 | 61 |
|
65 | | - - name: Updating Git release tag for the major "v${{steps.next_semantic_version.outputs.major}}" version |
66 | | - uses: ncipollo/release-action@v1 |
67 | | - with: # See https://github.com/softprops/action-gh-release#-customizing |
68 | | - token: "${{ secrets.GITHUB_TOKEN }}" |
| 62 | + # Check if the major version already exists (if it doesn't, we'll create it - if it does, we'll update it) |
| 63 | + - name: Check if tag "v${{steps.next_semantic_version.outputs.major}}" exists |
| 64 | + |
| 65 | + id: majorTagExists |
| 66 | + with: # See https://github.com/mukunku/tag-exists-action#inputs |
69 | 67 | tag: "v${{steps.next_semantic_version.outputs.major}}" |
70 | | - name: "v${{steps.next_semantic_version.outputs.major}} latest release (auto-update)" |
71 | | - allowUpdates: true |
72 | | - removeArtifacts: true |
73 | | - replacesArtifacts: true |
74 | | - prerelease: false |
75 | | - generateReleaseNotes: true |
76 | | - artifacts: | |
77 | | - CHANGELOG.md |
| 68 | + |
| 69 | + - run: "echo \"Check if majorTagExists: ${{ steps.majorTagExists.outputs.exists }}\"" |
| 70 | + |
| 71 | + # See https://cli.github.com/manual/gh_release_create |
| 72 | + - name: Creating new release for the major "v${{steps.next_semantic_version.outputs.major}}" version |
| 73 | + if: ${{ steps.majorTagExists.outputs.exists == 'false' }} |
| 74 | + run: | |
| 75 | + gh release create v${{steps.next_semantic_version.outputs.major}} \ |
| 76 | + --title "v${{steps.next_semantic_version.outputs.major}} MAJOR release (auto-updated)" \ |
| 77 | + --latest \ |
| 78 | + --generate-notes \ |
| 79 | + --target $GITHUB_SHA |
| 80 | + env: |
| 81 | + GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 82 | + |
| 83 | + # See https://cli.github.com/manual/gh_release_edit |
| 84 | + - name: Updating existing release for the major "v${{steps.next_semantic_version.outputs.major}}" version |
| 85 | + if: ${{ steps.majorTagExists.outputs.exists == 'true' }} |
| 86 | + run: | |
| 87 | + gh release edit v${{steps.next_semantic_version.outputs.major}} \ |
| 88 | + --title "v${{steps.next_semantic_version.outputs.major}} MAJOR release (auto-updated)" \ |
| 89 | + --latest \ |
| 90 | + --target $GITHUB_SHA |
| 91 | + env: |
| 92 | + GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 93 | + |
| 94 | + # Check if the minor version already exists (if it doesn't, we'll create it - if it does, we'll update it) |
| 95 | + - name: Check if tag "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}" exists |
| 96 | + |
| 97 | + id: minorTagExists |
| 98 | + with: # See https://github.com/mukunku/tag-exists-action#inputs |
| 99 | + tag: "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}" |
| 100 | + |
| 101 | + - run: "echo \"Check if minorTagExists: ${{ steps.minorTagExists.outputs.exists }}\"" |
| 102 | + |
| 103 | + # See https://cli.github.com/manual/gh_release_create |
| 104 | + - name: Creating new release for the minor "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}" version |
| 105 | + if: ${{ steps.minorTagExists.outputs.exists == 'false' }} |
| 106 | + run: | |
| 107 | + gh release create v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} \ |
| 108 | + --title "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} MINOR release (auto-updated)" \ |
| 109 | + --generate-notes \ |
| 110 | + --latest \ |
| 111 | + --target $GITHUB_SHA |
| 112 | + env: |
| 113 | + GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 114 | + |
| 115 | + # See https://cli.github.com/manual/gh_release_edit |
| 116 | + - name: Updating existing release for the minor "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}" version |
| 117 | + if: ${{ steps.minorTagExists.outputs.exists == 'true' }} |
| 118 | + run: | |
| 119 | + gh release edit v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} \ |
| 120 | + --title "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} MINOR release (auto-updated)" \ |
| 121 | + --latest \ |
| 122 | + --target $GITHUB_SHA |
| 123 | + env: |
| 124 | + GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
0 commit comments