mirror of
https://github.com/renovatebot/github-action.git
synced 2025-12-16 08:52:35 +00:00
feat(ci): auto release (#53)
* feat(ci): allow auto release * chore(ci): simplify release * chore: apply suggestions from code review
This commit is contained in:
parent
1dd736bd72
commit
6cef3bd05f
5 changed files with 94 additions and 56 deletions
53
.github/workflows/release.yml
vendored
53
.github/workflows/release.yml
vendored
|
|
@ -7,10 +7,7 @@ jobs:
|
|||
release:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
github.event.commits[0].message == 'chore(release): trigger release process [ci release]' ||
|
||||
github.event.commits[0].message == 'chore(release): trigger release process [ci release][major]' ||
|
||||
github.event.commits[0].message == 'chore(release): trigger release process [ci release][minor]' ||
|
||||
github.event.commits[0].message == 'chore(release): trigger release process [ci release][patch]'
|
||||
startsWith(github.event.commits[0].message, 'fix(deps): update renovate/renovate docker tag ')
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.1.0
|
||||
|
|
@ -30,30 +27,34 @@ jobs:
|
|||
run: npm ci
|
||||
- name: Release
|
||||
run: |
|
||||
readonly COMMIT_MESSAGE="${{ github.event.commits[0].message }}"
|
||||
if [[ "${COMMIT_MESSAGE: -11: -1}" == 'ci release' ]]; then
|
||||
echo "::set-env name=NEXT_VERSION::$(npm run release:version --silent)"
|
||||
npx --no-install standard-version
|
||||
else
|
||||
readonly RELEASE_TYPE="${COMMIT_MESSAGE: -6: -1}"
|
||||
echo "::set-env name=NEXT_VERSION::$(
|
||||
npm run release:version --silent -- --releaseAs "${RELEASE_TYPE}"
|
||||
)"
|
||||
npx --no-install standard-version --release-as "${RELEASE_TYPE}"
|
||||
SEMVER_REGEX="v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)"
|
||||
if [[ ! "${{ github.event.commits[0].message }}" =~ ${SEMVER_REGEX} ]]; then
|
||||
echo Not a semver like version - aborting: ${1}
|
||||
exit 1
|
||||
fi
|
||||
NEXT_VERSION="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}"
|
||||
MAJOR_VERSION="${BASH_REMATCH[1]}"
|
||||
echo "::set-env name=NEXT_VERSION::${NEXT_VERSION}"
|
||||
echo "::set-env name=MAJOR_VERSION::${MAJOR_VERSION}"
|
||||
npm version ${NEXT_VERSION} -m "chore(release): ${NEXT_VERSION}"
|
||||
git tag "v${MAJOR_VERSION}"
|
||||
|
||||
- name: Publish release
|
||||
run: git push --follow-tags
|
||||
- name: Publish GitHub release
|
||||
uses: actions/create-release@v1.0.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: v${{ env.NEXT_VERSION }}
|
||||
release_name: v${{ env.NEXT_VERSION }}
|
||||
body: |
|
||||
See the the [changelog](
|
||||
https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md
|
||||
) for the changes included in this release.
|
||||
run: |
|
||||
git push origin "v${NEXT_VERSION}"
|
||||
git push -f origin "v${MAJOR_VERSION}"
|
||||
|
||||
# - name: Publish GitHub release
|
||||
# uses: actions/create-release@v1.0.1
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# with:
|
||||
# tag_name: v${{ env.NEXT_VERSION }}
|
||||
# release_name: v${{ env.NEXT_VERSION }}
|
||||
# body: |
|
||||
# See the the [changelog](
|
||||
# https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md
|
||||
# ) for the changes included in this release.
|
||||
prevent_failed_status:
|
||||
name: Prevent failed status when skipped
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue