88 lines
2.9 KiB
YAML
88 lines
2.9 KiB
YAML
name: Create Semver Release
|
|
description: Uses tags and semver type to push a tag on the latest commit
|
|
author: Skydust
|
|
|
|
# Define your inputs here.
|
|
inputs:
|
|
semver:
|
|
type: choice
|
|
description: Choose the semver
|
|
options:
|
|
- "Major - Incompatible API changes"
|
|
- "Minor - Adding functionality in a backward compatible manner"
|
|
- "Patch - Backward compatible bug fixes"
|
|
new_branch_on:
|
|
type: choice
|
|
description: Makes a new branch on
|
|
options:
|
|
- "Major"
|
|
- "Minor"
|
|
- "Never"
|
|
required: false
|
|
default: "Major"
|
|
token:
|
|
description: 'A Gitea PAT'
|
|
required: true
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: '0'
|
|
- name: Checking if ran on the dev branch
|
|
run: |
|
|
if [[ "${{ github.ref }}" != refs/heads/dev ]]; then
|
|
log_info $(red)ERROR$(reset_color) This can only be ran on the dev branch
|
|
exit 1
|
|
fi
|
|
- name: Getting version
|
|
uses: https://gitea.skydust.fr/actions/get-version@v1
|
|
with:
|
|
semver: "${{ inputs.semver }}"
|
|
- name: Get new version
|
|
run: |
|
|
if ! [[ "${NEW_VERSION}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(-[0-9A-Za-z-.]+)?(\+[0-9A-Za-z-.]+)?$ ]]; then
|
|
log_info "$(red)ERROR$(reset_color) The version $(yellow)${NEW_VERSION}$(reset_color) is not valid for a release"
|
|
exit 1
|
|
fi
|
|
- name: Setting up release git account
|
|
run: |
|
|
git config user.email "release@example.com"
|
|
git config user.name "Release"
|
|
|
|
log_info "Overriding git repository auth with PAT"
|
|
|
|
repo_url="$(git remote get-url origin)"
|
|
repo_url="${repo_url#https://}" # Remove HTTPS
|
|
GIT_NEW_URL="https://MilaBot:${{ inputs.token }}@${repo_url}.git"
|
|
|
|
git remote set-url origin "$GIT_NEW_URL"
|
|
git config --local --unset http.https://${GITHUB_SERVER_URL#https://}/.extraheader
|
|
- name: Pushing new version
|
|
run: |
|
|
if [[ -n "${{ inputs.semver }}" ]]]]; then
|
|
SEMVER_UPDATE="${{ inputs.semver }}"
|
|
fi
|
|
|
|
log_info "Pushing new tag"
|
|
git fetch
|
|
git tag -a "v${NEW_VERSION}" -m "Release version ${NEW_VERSION}"
|
|
git push origin "v${NEW_VERSION}"
|
|
|
|
if { [[ "${{ inputs.new_branch_on }}" == "Minor"* ]] &&
|
|
{ [[ "${SEMVER_UPDATE}" == "Major"* ]] || [[ "${SEMVER_UPDATE}" == "Minor"* ]]; }; } ||
|
|
{ [[ "${{ inputs.new_branch_on }}" == "Major"* ]] && [[ "${SEMVER_UPDATE}" == "Minor"* ]]; }; then
|
|
|
|
log_info "${{ inputs.new_branch_on }} version, creating release branch for backports"
|
|
git branch "release/v${NEW_VERSION}"
|
|
git push origin "release/v${NEW_VERSION}"
|
|
fi
|
|
- name: Fast forwarding master branch to dev
|
|
run: |
|
|
log_info "Fast-forwarding master to dev"
|
|
git checkout master
|
|
git merge --ff-only origin/dev
|
|
git push
|