|
| 1 | +# Description |
| 2 | +# =========== |
| 3 | +# This workflow is triggered each time a milestone is closed |
| 4 | +# It builds the jar, generates release notes, pushes a new tag |
| 5 | +# and makes a draft release with these elements. |
| 6 | +--- |
| 7 | +name: Draft Release |
| 8 | + |
| 9 | +on: |
| 10 | + milestone: |
| 11 | + types: [closed] |
| 12 | + |
| 13 | +jobs: |
| 14 | + release: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Check out repository code |
| 18 | + uses: actions/checkout@v2 |
| 19 | + - name: Setup java |
| 20 | + uses: actions/setup-java@v2 |
| 21 | + with: |
| 22 | + distribution: 'adopt' |
| 23 | + java-version: '11' |
| 24 | + - name: Cache Maven packages |
| 25 | + uses: actions/cache@v2 |
| 26 | + with: |
| 27 | + path: ~/.m2 |
| 28 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 29 | + restore-keys: ${{ runner.os }}-m2 |
| 30 | + - name: Build with Maven |
| 31 | + run: mvn -B clean package |
| 32 | + - name: Create Release Notes |
| 33 | + uses: docker://decathlon/release-notes-generator-action:2.0.1 |
| 34 | + env: |
| 35 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + OUTPUT_FOLDER: temp_release_notes |
| 37 | + - name: Set tag and project values |
| 38 | + run: | |
| 39 | + echo "tag=$(cat pom.xml | grep "<version>.*</version>" | head -1 |awk -F'[><]' '{print $3}')" >> $GITHUB_ENV |
| 40 | + echo "project=$(echo ${{ github.repository }} | awk -F '/' '{print $2}')" >> $GITHUB_ENV |
| 41 | + - name: Create a tag for the release |
| 42 | + run: | |
| 43 | + git config --global user.name "GitHub Actions" |
| 44 | + git config --global user.email [email protected] |
| 45 | + git tag -a ${{ env.tag }} -m "Release ${{ env.tag }}" |
| 46 | + git push origin ${{ env.tag }} |
| 47 | + - name: Create GitHub Release |
| 48 | + uses: ncipollo/release-action@v1 |
| 49 | + env: |
| 50 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + with: |
| 52 | + artifacts: "target/${{ env.project }}-${{ env.tag }}.jar" |
| 53 | + tag: ${{ env.tag }} |
| 54 | + name: ${{ env.project }} ${{ env.tag }} |
| 55 | + bodyFile: "temp_release_notes/release_file.md" |
| 56 | + draft: true |
| 57 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments