mirror of
https://github.com/neon-mmd/websurfx.git
synced 2024-11-26 15:58:21 -05:00
Merge pull request #6 from scottc943/FEATURE/400_GitHubActions-automate-release-versions
ci: changing structure of release.yml to be easier to understand
This commit is contained in:
commit
17cc2b4ef2
116
.github/workflows/release.yml
vendored
116
.github/workflows/release.yml
vendored
@ -16,99 +16,35 @@ jobs:
|
|||||||
if: github.event.pull_request.merged == true
|
if: github.event.pull_request.merged == true
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
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
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Bumping Major Index
|
- name: 'Automated Version Bump'
|
||||||
id: bump_version_major
|
id: version-bump
|
||||||
if: contains(github.event.pull_request.title, 'major')
|
uses: 'phips28/gh-action-bump-version@master'
|
||||||
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:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
with:
|
||||||
create_release() {
|
major-wording: 'MAJOR,major-change'
|
||||||
local version="${1}"
|
minor-wording: 'feat,'
|
||||||
if [ -n "${version}" ]; then
|
patch-wording: 'patch,fix,build,chore,ci,docs,style,refactor,perf,test' # Providing patch-wording will override commits
|
||||||
version="v${version}"
|
tag-prefix: 'v'
|
||||||
fi
|
default: patch
|
||||||
curl \
|
- name: Changelog
|
||||||
-X POST \
|
uses: scottbrenner/generate-changelog-action@master
|
||||||
-H "Accept: application/vnd.github+json" \
|
id: Changelog
|
||||||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
env:
|
||||||
https://api.github.com/repos/${repo}/releases \
|
REPO: ${{ github.repository }}
|
||||||
-d '{"tag_name":"'"${version}"'","target_commitish":"'"${branch}"'","name":"'"${version}"'","body":"","draft":false,"prerelease":false,"generate_release_notes":true}'
|
- 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