diff --git a/.github/workflows/changelog.yaml b/.github/workflows/changelog.yaml new file mode 100644 index 0000000..b8925ad --- /dev/null +++ b/.github/workflows/changelog.yaml @@ -0,0 +1,50 @@ +name: Update Changelog + +concurrency: ci-${{ github.ref }} +on: + push: + branches: + - main + workflow_run: + workflows: ["Tag & Release"] + branches: [main] + types: + - completed + +jobs: + changelog: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Generate Changelog + uses: heinrichreimer/github-changelog-generator-action@v2.2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + headerLabel: "# 📑 Changelog" + breakingLabel: '### 💥 Breaking' + enhancementLabel: '### 🚀 Enhancements' + bugsLabel: '### 🐛 Bug fixes' + securityLabel: '### 🛡️ Security' + issuesLabel: '### 📁 Other issues' + prLabel: '### 📁 Other pull requests' + addSections: '{"documentation":{"prefix":"### 📖 Documentation","labels":["documentation"]},"tests":{"prefix":"### ✅ Testing","labels":["tests"]}}' + issues: true + issuesWoLabels: true + pullRequests: true + prWoLabels: true + author: true + unreleased: true + compareLink: true + stripGeneratorNotice: true + verbose: true + + - name: Commit Changelog + run: | + git config user.name "GitHub Actions" + git config user.email noreply@github.com + git add CHANGELOG.md + git commit -m 'Update Changelog.' + git push + diff --git a/.github/workflows/javadocs.yaml b/.github/workflows/javadocs.yaml new file mode 100644 index 0000000..7c809c4 --- /dev/null +++ b/.github/workflows/javadocs.yaml @@ -0,0 +1,44 @@ +name: Update JavaDocs + +concurrency: ci-${{ github.ref }} +on: + workflow_run: + workflows: ["Tag & Release"] + branches: [main] + types: + - completed + +jobs: + generate-javadocs: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: 'main' + + - name: Setup JDK + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: 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: Build JavaDocs + run: mvn -U clean verify -Pgenerate-site-javadoc + + - name: Commit JavaDocs + run: | + git config user.name "GitHub Actions" + git config user.email noreply@github.com + git add docs + git commit -m 'Updating JavaDocs.' + git push + diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 17203a3..5c2f77f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -4,11 +4,11 @@ on: workflow_dispatch: inputs: version: - description: Tag/Version + description: Version required: false jobs: - tag-release: + tag: runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' @@ -45,14 +45,15 @@ jobs: run: echo "::set-output name=version::$(grep ^scm.tag= release.properties | sed -e 's/scm.tag=aio-lib-cloudmanager-//g')" github-release: - needs: tag-release + needs: tag runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 with: - ref: aio-lib-cloudmanager-${{ needs.tag-release.outputs.version }} + fetch-depth: 0 # Work around for https://github.com/heinrichreimer/action-github-changelog-generator/issues/21 + ref: aio-lib-cloudmanager-${{ needs.tag.outputs.version }} - name: Setup JDK uses: actions/setup-java@v1 @@ -68,77 +69,54 @@ jobs: ${{ runner.os }}-maven- - name: Maven Verify - run: mvn -U clean verify + run: mvn -U clean verify && mvn verify -P java8 + + - name: Generate Release Changelog + id: generate-release-changelog + uses: heinrichreimer/github-changelog-generator-action@v2.2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + issues: true + issuesWoLabels: true + pullRequests: true + prWoLabels: true + author: true + compareLink: true + onlyLastTag: true + stripHeaders: true + stripGeneratorNotice: true - name: Create Release - id: create_release + id: create-release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: aio-lib-cloudmanager-${{ needs.tag-release.outputs.version }} - release_name: aio-lib-cloudmanager-${{ needs.tag-release.outputs.version }} - body: | - See [Changelog](/CHANGELOG.md) for details. + tag_name: aio-lib-cloudmanager-${{ needs.tag.outputs.version }} + release_name: aio-lib-cloudmanager-${{ needs.tag.outputs.version }} + body: ${{ steps.generate-release-changelog.outputs.changelog }} draft: false prerelease: false - - name: Upload Jar - id: upload-release-jar - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./target/aio-lib-cloudmanager-${{ needs.tag-release.outputs.version }}.jar - asset_name: aio-lib-cloudmanager-${{ needs.tag-release.outputs.version }}.jar - asset_content_type: application/java-archive - - - name: Upload JavaDoc Jar - id: upload-release-javadoc - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./target/aio-lib-cloudmanager-${{ needs.tag-release.outputs.version }}-javadoc.jar - asset_name: aio-lib-cloudmanager-${{ needs.tag-release.outputs.version }}-javadoc.jar - asset_content_type: application/java-archive - - - name: Upload Sources Jar - id: upload-release-sources - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./target/aio-lib-cloudmanager-${{ needs.tag-release.outputs.version }}-sources.jar - asset_name: aio-lib-cloudmanager-${{ needs.tag-release.outputs.version }}-sources.jar - asset_content_type: application/java-archive - - - name: Maven Verify - run: mvn -U clean verify -P java8 - - - name: Upload Java8 Jar - id: upload-java8-release-jar - uses: actions/upload-release-asset@v1 + - name: Upload Release Artifacts + id: upload-release-artifacts + uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./target/aio-lib-cloudmanager-${{ needs.tag-release.outputs.version }}-java8.jar - asset_name: aio-lib-cloudmanager-${{ needs.tag-release.outputs.version }}-java8.jar - asset_content_type: application/java-archive + tag_name: aio-lib-cloudmanager-${{ needs.tag.outputs.version }} + files: | + ./target/aio-lib-cloudmanager-*.jar maven-central-deploy: - needs: tag-release + needs: tag runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 with: - ref: aio-lib-cloudmanager-${{ needs.tag-release.outputs.version }} + ref: aio-lib-cloudmanager-${{ needs.tag.outputs.version }} # See https://github.com/actions/setup-java#publishing-using-apache-maven - name: Setup JDK @@ -174,31 +152,9 @@ jobs: MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }} MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - - name: Publish to Apache Maven Central + - name: Publish Java8 to Apache Maven Central run: mvn clean deploy -P release,java8 -DautoReleaseAfterClose=true env: MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }} MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - - changelog: - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Generate Changelog - uses: heinrichreimer/github-changelog-generator-action@v2.2 - with: - issues: false - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Commit Changelog - run: | - git config user.name "GitHub Actions" - git config user.email noreply@github.com - git add CHANGELOG.md - git commit -m 'Update Changelog.' - git push diff --git a/.github/workflows/snapshot-deploy.yaml b/.github/workflows/snapshot-deploy.yaml index dbbf33a..83facab 100644 --- a/.github/workflows/snapshot-deploy.yaml +++ b/.github/workflows/snapshot-deploy.yaml @@ -1,4 +1,4 @@ -name: Deploy SNAPSHOT +name: Snapshot Deploy on: push: diff --git a/.github/workflows/maven-verify.yaml b/.github/workflows/verify.yaml similarity index 97% rename from .github/workflows/maven-verify.yaml rename to .github/workflows/verify.yaml index 6b4da93..c46a706 100644 --- a/.github/workflows/maven-verify.yaml +++ b/.github/workflows/verify.yaml @@ -1,4 +1,4 @@ -name: Build +name: Build & Verify on: pull_request: diff --git a/README.md b/README.md index 69fecda..5588a2a 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,38 @@ Contributions are welcomed! Read the [Contributing Guide](./.github/CONTRIBUTING Please run the and include the output from the `generate-javadoc` Maven profile for any Pull Requests, to keep the documentation up-to-date. +### GitHub Actions + +#### Tag & Release + +This is the only action that requires a user to activate manually. + +Releasing a version of the library can be done by activating the [Tag & Release](./actions/workflows/release.yaml) action. + +The version is optional, if unspecified it will use whatever Maven determines is the next release. + +#### Snapshot Deploy + +Activated on every commit to the `main` branch. + +Automatically deploy a SNAPSHOT of the current build to Maven Central's snapshot repository. + +#### Build & Verify + +Activated on every pull request to the `main` branch. + +Automatically run a build and tests for the project. + +#### Update Changelog + +Activated on every commit to the `main` branch. + +This will automatically update the [Changelog](./CHANGELOG.md) from Pull Requests or Issues, and commit it back to the `main` branch. + +#### Update JavaDoc + +Activated after every successful [Tag & Release](#tag--release) run. This will run the Maven profile for generating the Project JavaDocs and commit them back to the `main` branch. This will keep them always up-to-date with the latest release. + ### Licensing This project is licensed under the Apache V2 License. See [LICENSE](LICENSE) for more information.