Skip to content

Commit

Permalink
New version and CI strategy (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
leviem1 authored Jul 6, 2021
1 parent 0a74b12 commit fd3e0a7
Show file tree
Hide file tree
Showing 10 changed files with 305 additions and 162 deletions.
54 changes: 6 additions & 48 deletions .github/workflows/artifact.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
name: Build and Artifact
name: Build Artifact

on:
pull_request:
branches:
- 'main'

push:
branches:
- 'main'

schedule:
- cron: '0 0 * * 6'

Expand All @@ -20,7 +16,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
java: [11, 16]
java: [ 11, 16 ]
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -36,49 +32,11 @@ jobs:
run: chmod +x gradlew

- name: Build with Gradle
if: runner.os == 'Linux'
run: ./gradlew -Pver=${GITHUB_RUN_NUMBER} build --info

- name: Build with Gradle
if: runner.os == 'Windows'
run: ./gradlew "-Pver=$env:GITHUB_RUN_NUMBER" build --info
run: ./gradlew build --info

- name: Upload artifact
- name: Upload build results
if: ${{ always() }}
uses: actions/upload-artifact@v2.2.4
with:
name: ${{ matrix.os }} Java ${{ matrix.java }} build
path: |
${{ github.workspace }}/build
notify:
needs: artifact
runs-on: ubuntu-latest
env:
DISCORD_WEBHOOK_ID: ${{ secrets.DISCORD_WEBHOOK_ID }}
DISCORD_WEBHOOK_TOKEN: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
if: ${{ always() }}
steps:
- name: Notify on success
if: ${{ env.DISCORD_WEBHOOK_ID != null && env.DISCORD_WEBHOOK_TOKEN != null && needs.artifact.result == 'success' }}
uses: appleboy/discord-action@0.0.3
with:
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
color: "#00FF00"
username: "CW Build Status Bot"
message: >
${{ github.repository }} build ${{ github.run_number }} successfully completed:
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Notify on failure
if: ${{ env.DISCORD_WEBHOOK_ID != null && env.DISCORD_WEBHOOK_TOKEN != null && needs.artifact.result == 'failure' }}
uses: appleboy/discord-action@0.0.3
with:
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
color: "#FF0000"
username: "CW Build Status Bot"
message: >
${{ github.repository }} build ${{ github.run_number }} failed:
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
name: ${{ matrix.os }} Java ${{ matrix.java }} build results
path: ${{ github.workspace }}/build/
34 changes: 0 additions & 34 deletions .github/workflows/check.yml

This file was deleted.

59 changes: 0 additions & 59 deletions .github/workflows/draft.yml

This file was deleted.

123 changes: 123 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Publish Release

on:
push:
tags:
- 'v*' # For v1.0, v0.1.0, etc

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
java: [ 11, 16 ]
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'

- name: Grant execute permission for gradlew
if: runner.os == 'Linux'
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build --info

- name: Upload build results
if: ${{ always() }}
uses: actions/upload-artifact@v2.2.4
with:
name: ${{ matrix.os }} Java ${{ matrix.java }} build results
path: ${{ github.workspace }}/build/

release:
needs: build
runs-on: ubuntu-latest
env:
SPS_MVN_USER: ${{ secrets.SPS_MVN_USER }}
SPS_MVN_PASS: ${{ secrets.SPS_MVN_PASS }}
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 11
distribution: 'zulu'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Publish with Gradle
run: ./gradlew -Pver=${GITHUB_REF/refs\/tags\//} release

- name: Upload artifact
uses: actions/upload-artifact@v2.2.4
with:
name: Release Jar(s)
path: ${{ github.workspace }}/build/libs/

- name: Draft GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
body: |
# Recent Changes
## Improvements 🏗️
* Item 1
## Bug Fixes 🐞
* Item 2
- name: Upload GitHub Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/build/libs/ExamplePlugin.jar
asset_name: ExamplePlugin.jar
asset_content_type: application/java-archive

bump-version:
needs: release
runs-on: ubuntu-latest
env:
PR_PAT: ${{ secrets.PR_PAT }}
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Bump project version
run: |
cat ${{ github.workspace }}/version.txt \
| awk -F. -v OFS=. 'BEGIN { ORS="" }; NF==1{print ++$NF}; NF>1{$NF=sprintf("%0*d", \
length ($NF), ($NF+1)); print}' \
| tee ${{ github.workspace }}/version.txt
- name: Create Pull Request
if: ${{ env.PR_PAT != null }}
uses: peter-evans/create-pull-request@v3
with:
assignees: leviem1
base: main
body: Bumps the project's Gradle version in version.txt
branch: bump-version
commit-message: Bump project version
delete-branch: true
labels: enhancement, low priority
title: Bump project version
token: ${{ secrets.PR_PAT }}
95 changes: 95 additions & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Build Snapshot

on:
push:
branches:
- 'main'

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
java: [ 11, 16 ]
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'

- name: Grant execute permission for gradlew
if: runner.os == 'Linux'
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build --info

- name: Upload build results
if: ${{ always() }}
uses: actions/upload-artifact@v2.2.4
with:
name: ${{ matrix.os }} Java ${{ matrix.java }} build results
path: ${{ github.workspace }}/build/

artifact:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: 11
distribution: 'zulu'

- name: Grant execute permission for gradlew
if: runner.os == 'Linux'
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build --info

- name: Upload artifact
uses: actions/upload-artifact@v2.2.4
with:
name: Snapshot Jar(s)
path: ${{ github.workspace }}/build/libs/

notify:
needs: artifact
runs-on: ubuntu-latest
env:
DISCORD_WEBHOOK_ID: ${{ secrets.DISCORD_WEBHOOK_ID }}
DISCORD_WEBHOOK_TOKEN: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
if: ${{ always() }}
steps:
- name: Notify on success
if: ${{ env.DISCORD_WEBHOOK_ID != null && env.DISCORD_WEBHOOK_TOKEN != null && needs.artifact.result == 'success' }}
uses: appleboy/discord-action@0.0.3
with:
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
color: "#00FF00"
username: "CW Build Status Bot"
message: >
${{ github.repository }} build ${{ github.run_number }} successfully completed:
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Notify on failure
if: ${{ env.DISCORD_WEBHOOK_ID != null && env.DISCORD_WEBHOOK_TOKEN != null && needs.artifact.result == 'failure' }}
uses: appleboy/discord-action@0.0.3
with:
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
color: "#FF0000"
username: "CW Build Status Bot"
message: >
${{ github.repository }} build ${{ github.run_number }} failed:
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
Loading

0 comments on commit fd3e0a7

Please sign in to comment.