Update blank.yml #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Version | |
on: | |
pull_request: | |
branches: [ "main" ] | |
push: | |
branches: [ "main" ] | |
workflow_dispatch: | |
jobs: | |
check-pr-title: | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
outputs: | |
versionType: ${{ steps.keyword.outputs.versionType }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get pull request title and check for major, minor or patch | |
id: keyword | |
run: | | |
if [[ "${{ github.event.pull_request.title }}" == *"major"* ]]; then | |
echo "versionType=major" >> "$GITHUB_OUTPUT" | |
elif [[ "${{ github.event.pull_request.title }}" == *"minor"* ]]; then | |
echo "versionType=minor" >> "$GITHUB_OUTPUT" | |
elif [[ "${{ github.event.pull_request.title }}" == *"patch"* ]]; then | |
echo "versionType=patch" >> "$GITHUB_OUTPUT" | |
else | |
echo "versionType=none" >> "$GITHUB_OUTPUT" | |
- name: Save version type | |
run: echo "${{ steps.keyword.outputs.versionType }}" > versionType.txt | |
- name: Upload version type artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: version-type | |
path: versionType.txt | |
release: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download version type artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: version-type | |
path: . | |
- name: Read version type | |
id: read-version-type | |
run: | | |
if [ -f versionType.txt ]; then | |
versionType=$(cat versionType.txt) | |
echo "VERSION_TYPE=$versionType" >> $GITHUB_ENV | |
else | |
echo "VERSION_TYPE=patch" >> $GITHUB_ENV | |
fi | |
- name: Get next version | |
uses: reecetech/[email protected] | |
id: version | |
with: | |
scheme: semver | |
increment: ${{ env.VERSION_TYPE }} | |
- name: Create version number file in release and update | |
run: echo ${{ steps.version.outputs.version }} > version | |
- name: Zip Release | |
run: zip -r release.zip . | |
- name: Upload Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: release.zip | |
prerelease: false | |
draft: false | |
tag_name: ${{ steps.version.outputs.version }} |