From 5d9500af21ff1c29fbef948aa1fe62dd0b955c8b Mon Sep 17 00:00:00 2001 From: David <32903114+SweedInsight@users.noreply.github.com> Date: Wed, 20 Jan 2021 05:41:32 +0100 Subject: [PATCH] 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 --- .github/workflows/main.yml | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..0c591a4 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,58 @@ +name: Master + +on: + push: + branches: + - master + paths-ignore: + - 'docs/**' + - '*.md' + +jobs: + get-publish-version: + runs-on: ubuntu-latest + outputs: + publish-version: ${{ steps.get-publish-version.outputs.publish-version }} + steps: + - name: Prepare SemVer + id: prepare-semver + run: | + LATEST_VERSION=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + [ -z "$LATEST_VERSION" ] && LATEST_VERSION="0.0.0" + echo ::set-output name=latest_version_out::$LATEST_VERSION + commit_message="${{ github.event.head_commit.message }}" + if [[ "${commit_message,,}" == *"major release"* ]]; then + echo ::set-output name=semver_increment::"m" + elif [[ "${commit_message,,}" == *"minor release"* ]]; then + echo ::set-output name=semver_increment::"i" + else + echo ::set-output name=semver_increment::"p" + fi + - name: Increment SemVer + id: semver + uses: matt-FFFFFF/simple-semver@v0.1.0 + with: + semver-input: ${{ steps.prepare-semver.outputs.latest_version_out }} + increment: ${{ steps.prepare-semver.outputs.semver_increment }} + - name: Get publish version + id: get-publish-version + run: echo "::set-output name=publish-version::${{ steps.semver.outputs.semver }}" + + + publish-github-release: + runs-on: ubuntu-latest + needs: [get-publish-version] + steps: + - name: Checkout code + uses: actions/checkout@master + - name: Create GitHub Release + id: create_release + uses: actions/create-release@latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ needs.get-publish-version.outputs.publish-version }} + release_name: Release ${{ needs.get-publish-version.outputs.publish-version }} + draft: false + prerelease: false +