Skip to content

(MAJOR) Update node from v16 to v20 (#106) #22

(MAJOR) Update node from v16 to v20 (#106)

(MAJOR) Update node from v16 to v20 (#106) #22

# Summary:
# Automatically tag and release when changes land on the "main" branch.
# It uses "semantic-version" to resolve the next version to use, and then we use GitHub CLI to create or update the releases.
#
# See https://github.com/PaulHatch/semantic-version https://github.com/PaulHatch/semantic-version/tree/v5.0.2
# See https://github.com/softprops/action-gh-release https://github.com/softprops/action-gh-release/tree/v1
name: 'Auto release'
on:
push:
branches:
- main
jobs:
tag-and-release:
runs-on: ubuntu-latest
steps:
- name: Fetching all commits for the current branch
uses: actions/checkout@v3
with:
fetch-depth: 0 # Force fetch all commits - See https://github.com/PaulHatch/semantic-version#important-note-regarding-the-checkout-action
- run: "echo \"GITHUB_SHA: ${{ github.sha }}\""
# Outputs documentation: https://github.com/PaulHatch/semantic-version/blob/master/src/main.ts#L22-L33
- name: Resolving next Release Candidate version using semantic-version
uses: paulhatch/[email protected]
id: next_semantic_version
with: # See https://github.com/PaulHatch/semantic-version#usage
tag_prefix: "v" # The prefix to use to identify tags
major_pattern: "(MAJOR)" # A string which, if present in a git commit, indicates that a change represents a major (breaking) change
minor_pattern: "(MINOR)" # Same as above except indicating a minor change
version_format: "${major}.${minor}.${patch}-rc.${increment}" # A string to determine the format of the version output
bump_each_commit: true # If this input is set to true, every commit will be treated as a new version, bumping the patch, minor, or major version based on the commit message.
- name: Printing semantic-version outputs (for debugging)
run: |
echo "Most useful outputs:"
echo "Next version: ${{steps.next_semantic_version.outputs.version}}"
echo "Next version tag: ${{steps.next_semantic_version.outputs.version_tag}}"
echo -e "\n All outputs:"
echo "version: ${{steps.next_semantic_version.outputs.version}}"
echo "major: ${{steps.next_semantic_version.outputs.major}}"
echo "minor: ${{steps.next_semantic_version.outputs.minor}}"
echo "patch: ${{steps.next_semantic_version.outputs.patch}}"
echo "increment: ${{steps.next_semantic_version.outputs.increment}}"
echo "version_type: ${{steps.next_semantic_version.outputs.version_type}}"
echo "changed: ${{steps.next_semantic_version.outputs.changed}}"
echo "authors: ${{steps.next_semantic_version.outputs.authors}}"
echo "version_tag: ${{steps.next_semantic_version.outputs.version_tag}}"
echo "previous_commit: ${{steps.next_semantic_version.outputs.previous_commit}}"
echo "current_commit: ${{steps.next_semantic_version.outputs.current_commit}}"
- name: Creating Git release tag for the "${{steps.next_semantic_version.outputs.version_tag}}" version
run: |
gh release create ${{steps.next_semantic_version.outputs.version_tag}} \
--title "${{steps.next_semantic_version.outputs.version_tag}}" \
--latest \
--generate-notes \
--target "${{github.sha}}"
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# Check if the major version already exists (if it doesn't, we'll create it - if it does, we'll update it)
- name: Check if tag "v${{steps.next_semantic_version.outputs.major}}" exists
uses: mukunku/[email protected]
id: majorTagExists
with: # See https://github.com/mukunku/tag-exists-action#inputs
tag: "v${{steps.next_semantic_version.outputs.major}}"
- run: "echo \"Check if majorTagExists: ${{ steps.majorTagExists.outputs.exists }}\""
# See https://cli.github.com/manual/gh_release_create
- name: Creating new release for the major "v${{steps.next_semantic_version.outputs.major}}" version
if: ${{ steps.majorTagExists.outputs.exists == 'false' }}
run: |
gh release create v${{steps.next_semantic_version.outputs.major}} \
--title "v${{steps.next_semantic_version.outputs.major}} MAJOR release (auto-updated)" \
--generate-notes \
--target "${{github.sha}}"
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# See https://cli.github.com/manual/gh_release_edit
- name: Recreating existing release for the major "v${{steps.next_semantic_version.outputs.major}}" version
if: ${{ steps.majorTagExists.outputs.exists == 'true' }}
run: |
# Delete and create the release again
gh release delete v${{steps.next_semantic_version.outputs.major}} --cleanup-tag --yes
gh release create v${{steps.next_semantic_version.outputs.major}} \
--title "v${{steps.next_semantic_version.outputs.major}} MAJOR release (auto-updated)" \
--generate-notes \
--target "${{github.sha}}"
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# Check if the minor version already exists (if it doesn't, we'll create it - if it does, we'll update it)
- name: Check if tag "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}" exists
uses: mukunku/[email protected]
id: minorTagExists
with: # See https://github.com/mukunku/tag-exists-action#inputs
tag: "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}"
- run: "echo \"Check if minorTagExists: ${{ steps.minorTagExists.outputs.exists }}\""
# See https://cli.github.com/manual/gh_release_create
- name: Creating new release for the minor "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}" version
if: ${{ steps.minorTagExists.outputs.exists == 'false' }}
run: |
gh release create v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} \
--title "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} MINOR release (auto-updated)" \
--generate-notes \
--target "${{github.sha}}"
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# See https://cli.github.com/manual/gh_release_edit
- name: Recreating existing release for the minor "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}}" version
if: ${{ steps.minorTagExists.outputs.exists == 'true' }}
run: |
# Delete and create the release again
gh release delete v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} --cleanup-tag --yes
gh release create v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} \
--title "v${{steps.next_semantic_version.outputs.major}}.${{steps.next_semantic_version.outputs.minor}} MINOR release (auto-updated)" \
--generate-notes \
--target "${{github.sha}}"
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"