0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-22 22:18:23 -05:00
websurfx/.github/workflows/release.yml

102 lines
4.0 KiB
YAML
Raw Normal View History

name: Bump release version
on:
pull_request:
branches: [rolling]
types:
- closed
permissions:
contents: write
concurrency: production
jobs:
build:
name: Create Release
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Taking the Latest Release Tag number
id: releaseVersion
run: |
repo="${{ github.repository }}"
latest_release=$(curl -s "https://api.github.com/repos/$repo/releases" | jq -r '.[0].name' )
latest_tag=$(curl -s "https://api.github.com/repos/$repo/tags" | jq -r '.[0].tag_name')
if [ -z "$latest_release" ] && [ -z "$latest_tag" ]; then
echo "No releases or tags found. Setting default version to 0.1.0"
Release_tag="v0.1.0"
elif [ -z "$latest_release" ]; then
echo "No releases found. Using latest tag version."
Release_tag=$latest_release
elif [ -z "$latest_tag" ]; then
echo "No tags found. Using latest release version."
Release_tag=$latest_release
elif [[ "$latest_release" > "$latest_tag" ]]; then
echo "Latest release is newer. Using release version."
Release_tag=$latest_release
else
echo "Latest tag is newer. Using tag version."
Release_tag=$latest_tag
fi
echo "::set-output name=Release_tag::$Release_tag"
- name: Checkout code
uses: actions/checkout@v2
- name: Bumping Major Index
id: bump_version_major
if: contains(github.event.pull_request.title, 'major')
uses: christian-draeger/increment-semantic-version@1.1.0
with:
current-version: ${{ steps.releaseVersion.outputs.Release_tag }}
version-fragment: 'major'
- name: Bumping Minor Index
id: bump_version_minor
if: contains(github.event.pull_request.title, 'feat')
uses: christian-draeger/increment-semantic-version@1.1.0
with:
current-version: ${{ steps.releaseVersion.outputs.Release_tag }}
version-fragment: 'feature'
- name: Bumping Patch Index
id: bump_version_patch
if: |
${{ contains(github.event.pull_request.title, 'patch') ||
contains(github.event.pull_request.title, 'build') ||
contains(github.event.pull_request.title, 'chore') ||
contains(github.event.pull_request.title, 'ci') ||
contains(github.event.pull_request.title, 'docs') ||
contains(github.event.pull_request.title, 'style') ||
contains(github.event.pull_request.title, 'refactor') ||
contains(github.event.pull_request.title, 'perf') ||
contains(github.event.pull_request.title, 'test') }}
uses: christian-draeger/increment-semantic-version@1.1.0
with:
current-version: ${{ steps.releaseVersion.outputs.Release_tag }}
version-fragment: 'bug'
- name: Create release version for bump_version_major
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
create_release() {
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${repo}/releases \
-d '{"tag_name":"'"${1}"'","target_commitish":"'"${branch}"'","name":"'"${1}"'","body":"","draft":false,"prerelease":false,"generate_release_notes":true}'
}
repo=${{ github.repository }}
branch=${{ github.head_ref }}
create_release "${{ steps.bump_version_major.outputs.next-version }}"
create_release "${{ steps.bump_version_minor.outputs.next-version }}"
create_release "${{ steps.bump_version_patch.outputs.next-version }}"