Skip to content
This repository was archived by the owner on Dec 5, 2023. It is now read-only.

Commit 5d9500a

Browse files
authored
Added GitHub Action to publish GitHub release on commit to default branch & SemVer (#9)
* added workflow script for publish * added workflow script for publish * remove image name * add check commit message job * fix workflow syntax * this is a Major Release * move Major Release type check to step in publish * add dummy output for Major and Minor Release * add dummy output for Major and Minor Release fix multiline * added step output Major Release * test step output Major Release * test step output Major Release * test step output Major Release * test step output Major Release * fix elif Minor Release * fix EOF Minor Release * tweak semver options * remove if for prepare * rework with semver action * test Minor Release * test Major Release * cleanup Minor Release Test * minor release case sensitivity check * minor release case sensitivity check2 * minor release case sensitivity check2 fix
1 parent c4a8604 commit 5d9500a

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

.github/workflows/main.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Master
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths-ignore:
8+
- 'docs/**'
9+
- '*.md'
10+
11+
jobs:
12+
get-publish-version:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
publish-version: ${{ steps.get-publish-version.outputs.publish-version }}
16+
steps:
17+
- name: Prepare SemVer
18+
id: prepare-semver
19+
run: |
20+
LATEST_VERSION=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
21+
[ -z "$LATEST_VERSION" ] && LATEST_VERSION="0.0.0"
22+
echo ::set-output name=latest_version_out::$LATEST_VERSION
23+
commit_message="${{ github.event.head_commit.message }}"
24+
if [[ "${commit_message,,}" == *"major release"* ]]; then
25+
echo ::set-output name=semver_increment::"m"
26+
elif [[ "${commit_message,,}" == *"minor release"* ]]; then
27+
echo ::set-output name=semver_increment::"i"
28+
else
29+
echo ::set-output name=semver_increment::"p"
30+
fi
31+
- name: Increment SemVer
32+
id: semver
33+
uses: matt-FFFFFF/[email protected]
34+
with:
35+
semver-input: ${{ steps.prepare-semver.outputs.latest_version_out }}
36+
increment: ${{ steps.prepare-semver.outputs.semver_increment }}
37+
- name: Get publish version
38+
id: get-publish-version
39+
run: echo "::set-output name=publish-version::${{ steps.semver.outputs.semver }}"
40+
41+
42+
publish-github-release:
43+
runs-on: ubuntu-latest
44+
needs: [get-publish-version]
45+
steps:
46+
- name: Checkout code
47+
uses: actions/checkout@master
48+
- name: Create GitHub Release
49+
id: create_release
50+
uses: actions/create-release@latest
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
with:
54+
tag_name: ${{ needs.get-publish-version.outputs.publish-version }}
55+
release_name: Release ${{ needs.get-publish-version.outputs.publish-version }}
56+
draft: false
57+
prerelease: false
58+

0 commit comments

Comments
 (0)