Skip to content

Commit

Permalink
Merge pull request #331 from pascalgrimaud/release-drafter-and-automa…
Browse files Browse the repository at this point in the history
…ted-release

Add Release Drafter and Automated Release
  • Loading branch information
pascalgrimaud authored Dec 17, 2021
2 parents 5549574 + 72708de commit 64d59de
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
template: |
## Release Notes
$CHANGES
exclude-contributors:
- 'dependabot'
- 'dependabot[bot]'
- 'github-actions[bot]'
change-template: '- $TITLE - [#$NUMBER]($URL) by @$AUTHOR'
categories:
- title: ⭐ Important fixes and improvements
labels:
- 'theme: important'
- title: 💎 Features & Enhancements
labels:
- 'area: enhancement :wrench:'
- 'area: feature request :bulb:'
- title: 🐞 Bug Fixes
labels:
- 'area: bug :bug:'
- title: 🖥️ Frontend
labels:
- 'client: angular'
- 'client: react'
- 'client: vue'
- title: 🍃 Spring Boot
labels:
- 'server: spring boot'
- title: 🔒 Authentication/Security
labels:
- 'theme: security'
- title: 🪶 Maven
labels:
- 'theme: maven'
- title: 🐘 Gradle
labels:
- 'theme: gradle'
- title: 📝 Documentation
label: 'area: documentation:books:'
- title: 📦 Dependency updates
label: 'theme: dependencies'
- title: 💩 Spam/Invalid
labels:
- 'area: spam'
- 'area: invalid'
11 changes: 10 additions & 1 deletion .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
branches:
- main
jobs:
#--------------------------------------------------
# Build and Tests the project
#--------------------------------------------------
tests:
name: tests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -44,6 +47,9 @@ jobs:
name: jar
path: '${{ github.workspace }}/target/*.jar'
retention-days: 1
#--------------------------------------------------
# Tests generated projects
#--------------------------------------------------
generation:
needs: tests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -77,6 +83,9 @@ jobs:
cd /tmp/beer/
chmod +x mvnw
./mvnw clean verify
#--------------------------------------------------
# Send analysis to Codecov
#--------------------------------------------------
codecov:
needs: generation
name: codecov
Expand All @@ -88,7 +97,7 @@ jobs:
uses: actions/download-artifact@v2
with:
name: jacoco
- name: 'Codecov: sending analyzis...'
- name: 'Codecov: sending analysis...'
uses: codecov/codecov-action@v2
with:
files: jacoco.xml
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release Drafter
on:
push:
branches:
- main
jobs:
update_release_draft:
if: github.repository == 'jhipster/jhipster-lite'
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
id: release-drafter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84 changes: 84 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Release
on:
push:
tags:
- "v*"
jobs:
#--------------------------------------------------
# Build and Tests the project
#--------------------------------------------------
tests:
name: tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: 'Setup: checkout project'
uses: actions/checkout@v2
- name: 'Setup: environment'
id: setup
uses: ./.github/actions/setup
- name: 'Init: cache local Maven repository'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: 'Init: install Node.js packages'
run: npm ci
- name: 'Check: prettier'
run: npm run prettier:check
- name: 'Test: run backend tests'
run: |
chmod +x mvnw
./mvnw clean verify
- name: 'Artifact: upload JAR'
uses: actions/upload-artifact@v2
with:
name: jar
path: '${{ github.workspace }}/target/*.jar'
retention-days: 1
#--------------------------------------------------
# Release
#--------------------------------------------------
release:
if: startsWith(github.event.ref, 'refs/tags/v')
name: release
needs: tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: 'Setup: checkout project'
uses: actions/checkout@v2
- name: 'Artifact: download JAR'
uses: actions/download-artifact@v2
with:
name: jar
path: ./target/
- name: 'Release: get variables from artifact'
id: artifact_variables
run: |
ARTIFACT_PATHNAME=$(ls target/*.jar | head -n 1)
ARTIFACT_NAME=$(basename $ARTIFACT_PATHNAME)
ARTIFACT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
echo ::set-output name=artifact_asset_name::${ARTIFACT_NAME}
echo ::set-output name=artifact_asset_path::${ARTIFACT_PATHNAME}
echo ::set-output name=artifact_version::${ARTIFACT_VERSION}
- name: 'Release: publish release drafter'
uses: release-drafter/release-drafter@v5
id: release-drafter-final
with:
publish: true
tag: v${{ steps.artifact_variables.outputs.artifact_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 'Release: upload artifact'
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release-drafter-final.outputs.upload_url }}
asset_name: ${{ steps.artifact_variables.outputs.artifact_asset_name }}
asset_path: ${{ steps.artifact_variables.outputs.artifact_asset_path }}
asset_content_type: application/java-archive
70 changes: 70 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

GIT_MAIN_BRANCH='main'
GIT_REMOTE='upstream'

show_syntax() {
echo "You want to release a new version"
echo " - current version: ${currentVersion}"
echo " - release version: ${releaseVersion} (which is a patch)"
echo " "
echo "Usage: $0 <patch|minor|major>" >&2
exit 1
}

currentVersion=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
releaseVersion=${currentVersion//-SNAPSHOT/}

checkGit=$(git status --porcelain|wc -l)
if [[ $checkGit != 0 ]]; then
echo "*** Check: there are uncommitted changes..."
show_syntax
fi

if [ "$#" -ne 1 ]; then
show_syntax
fi

echo "*** Git: update project..."
git switch $GIT_MAIN_BRANCH
git fetch $GIT_REMOTE
git rebase $GIT_REMOTE/$GIT_MAIN_BRANCH

if [[ "$1" == "patch" ]]; then
echo "*** Version: remove SNAPSHOT and keep the version"
./mvnw versions:set -DremoveSnapshot versions:commit -q

elif [[ "$1" == "minor" ]]; then
echo "*** Version: remove SNAPSHOT and change to minor version"
./mvnw versions:set -DremoveSnapshot versions:commit -q
./mvnw build-helper:parse-version versions:set \
-DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0 \
versions:commit -q
elif [[ "$1" == "major" ]]; then
echo "*** Version: remove SNAPSHOT and change to major version"
./mvnw versions:set -DremoveSnapshot versions:commit -q
./mvnw build-helper:parse-version versions:set \
-DnewVersion=\${parsedVersion.nextMajorVersion}.0.0 \
versions:commit -q
else
show_syntax
fi

echo "*** Git: commit, tag and push tag..."
releaseVersion=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
npm version "${releaseVersion}" --no-git-tag-version

git add . && git commit -m "Release v${releaseVersion}"
git tag -a v"${releaseVersion}" -m "Release v${releaseVersion}"
git push $GIT_REMOTE v"${releaseVersion}"

echo "*** Version: add SNAPSHOT"
./mvnw build-helper:parse-version versions:set \
-DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT \
versions:commit -q

echo "*** Git: commit, push to $GIT_MAIN_BRANCH..."
nextVersion=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
npm version "${nextVersion}" --no-git-tag-version
git add . && git commit -m "Update to next version v${nextVersion}"
git push $GIT_REMOTE $GIT_MAIN_BRANCH

0 comments on commit 64d59de

Please sign in to comment.