mirror of
https://github.com/neon-mmd/websurfx.git
synced 2024-11-22 14:08:23 -05:00
ci: changing structure of release.yml to be easier to understand
This commit is contained in:
parent
8e12d75404
commit
857f52ba28
118
.github/workflows/release.yml
vendored
118
.github/workflows/release.yml
vendored
@ -16,99 +16,35 @@ jobs:
|
||||
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_tag
|
||||
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:
|
||||
- name: 'Automated Version Bump'
|
||||
id: version-bump
|
||||
uses: 'phips28/gh-action-bump-version@master'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
create_release() {
|
||||
local version="${1}"
|
||||
if [ -n "${version}" ]; then
|
||||
version="v${version}"
|
||||
fi
|
||||
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":"'"${version}"'","target_commitish":"'"${branch}"'","name":"'"${version}"'","body":"","draft":false,"prerelease":false,"generate_release_notes":true}'
|
||||
}
|
||||
with:
|
||||
major-wording: 'MAJOR,major-change'
|
||||
minor-wording: 'feat,'
|
||||
patch-wording: 'patch,fix,build,chore,ci,docs,style,refactor,perf,test' # Providing patch-wording will override commits
|
||||
tag-prefix: 'v'
|
||||
default: patch
|
||||
- name: Changelog
|
||||
uses: scottbrenner/generate-changelog-action@master
|
||||
id: Changelog
|
||||
env:
|
||||
REPO: ${{ github.repository }}
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@latest
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ steps.version-bump.outputs.newTag }}
|
||||
release_name: ${{ steps.version-bump.outputs.newTag }}
|
||||
body: |
|
||||
${{ steps.Changelog.outputs.changelog }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
repo=${{ github.repository }}
|
||||
branch=${{ github.head_ref }}
|
||||
|
||||
# Check if steps are defined before calling create_release so we don't do unnecessary steps
|
||||
if [ -n "${{ steps.bump_version_major.outputs.next-version }}" ]; then
|
||||
create_release "${{ steps.bump_version_major.outputs.next-version }}"
|
||||
fi
|
||||
|
||||
if [ -n "${{ steps.bump_version_minor.outputs.next-version }}" ]; then
|
||||
create_release "${{ steps.bump_version_minor.outputs.next-version }}"
|
||||
fi
|
||||
|
||||
if [ -n "${{ steps.bump_version_patch.outputs.next-version }}" ]; then
|
||||
create_release "${{ steps.bump_version_patch.outputs.next-version }}"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user