{"id":16179294,"url":"https://github.com/jonashackt/github-actions-release-maven","last_synced_at":"2025-04-07T11:43:30.574Z","repository":{"id":147269749,"uuid":"329239069","full_name":"jonashackt/github-actions-release-maven","owner":"jonashackt","description":"Showing how to release to Maven Central using GitHub Actions, create a GitHub release with commitlogs and publishing SNAPSHOT versions to GitHub Packages","archived":false,"fork":false,"pushed_at":"2021-02-07T17:20:39.000Z","size":4046,"stargazers_count":17,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-13T14:24:31.002Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://blog.codecentric.de/github-actions-pipeline","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonashackt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-13T08:18:06.000Z","updated_at":"2025-01-03T11:09:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"49678e09-8d98-4ac0-8766-f58e1120749e","html_url":"https://github.com/jonashackt/github-actions-release-maven","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fgithub-actions-release-maven","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fgithub-actions-release-maven/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fgithub-actions-release-maven/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fgithub-actions-release-maven/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonashackt","download_url":"https://codeload.github.com/jonashackt/github-actions-release-maven/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648923,"owners_count":20972942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T05:26:39.465Z","updated_at":"2025-04-07T11:43:30.538Z","avatar_url":"https://github.com/jonashackt.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# github-actions-release-maven\nShowing how to release to Maven Central using GitHub Actions, create a GitHub release with commitlogs and publishing SNAPSHOT versions to GitHub Packages\n\n# Release to Maven Central using GitHub Actions\n\nFor having a release workflow with GitHub Actions it would be nice not create another workflow file, since we don't want to \"pollut\" the existing push workflow. Therefore...\n\n\n### How to implement multiple GitHub Actions\n\nSee https://stackoverflow.com/a/57610640/4964553 - simply put multiple .yml files into ./github/workflows like:\n\nbuild.yml\n```yaml\nname: build\n\non: [push]\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n    ...\n```\n\nrelease-to-maven-central.yml\n```yaml\nname: release-to-maven-central\non:\n  release:\n    types: [created]\njobs:\n  publish:\n    runs-on: ubuntu-latest\n    steps:\n      ...\n```\n\n\n\n### How to manually trigger a GitHub action on: XYZ?\n\nThere's a great feature on how to trigger GitHub Actions through the GitHub Actions GUI described here: https://docs.github.com/en/free-pro-team@latest/actions/managing-workflow-runs/manually-running-a-workflow\n\nWith a manual \"release\" trigger through the GitHub Actions GUI, we need to use a manual event (as described here https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#manual-events) in a new `release-to-maven-central.yml` inside our `.github/workflows` directory:\n\n```yaml\nname: release-to-maven-central\non:\n  workflow_dispatch:\n    inputs:\n      releaseversion:\n        description: 'Release version'\n        required: true\n        default: '2.4.0'\njobs:\n  publish:\n    runs-on: ubuntu-latest\n    steps:\n    - run: |\n        echo \"Release version ${{ github.event.inputs.releaseversion }}!\"\n```\n\nUsing the `workflow_dispatch:inputs` field we can even configure a GUI element where we can set the release version dynamically.\n\nOk it seams, we need to merge this workflow to master/main first - since:\n\n\u003e To trigger the workflow_dispatch event on GitHub, your workflow must be in the default branch.\n\nNow it should look like this:\n\n![github-actions-run-first-workflow](screenshots/manually-trigger-release-workflow.png)\n\nIf you let the workflow run by clicking on `run workflow`, it should print out our version:\n\n![manual-run-with-variable](screenshots/manual-run-with-variable.png)\n\n\n### How to release to Maven Central\n\nThe Actions docs are here: https://docs.github.com/en/free-pro-team@latest/actions/guides/publishing-java-packages-with-maven and they state, that the `setup-java` action already comes with a pre-configured `settings.xml`:\n\n\u003e \"...it also configures a Maven settings.xml for publishing packages. By default, the settings file will be configured for GitHub Packages, but it can be configured to deploy to another package registry, such as the Maven Central Repository.\"\n\nSo first we need to create some variables containing the credentials for the Sonatype Maven repo (see the Sonatype docs also: https://central.sonatype.org/pages/apache-maven.html).\n\n\n### Create encrypted variables in GitHub Actions\n\nTo create encrypted variables in GitHub Actions, have a look at https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets .\n\nWe need both `OSS_SONATYPE_USERNAME` and `OSS_SONATYPE_PASSWORD` for the Sonatype Nexus access and also `MAVEN_GPG_PRIVATE_KEY` and `MAVEN_GPG_PASSPHRASE` for the signing of our artifacts that will get uploaded. Therefor head over to the `Settings` tab of your repository and go to `Secrets`. There should be a button `New repository secret`:\n\n![repository-secrets](screenshots/repository-secrets.png)\n\nIf you ask yourself, which `gpg` file you need to use for `MAVEN_GPG_PRIVATE_KEY` have a look at https://central.sonatype.org/pages/working-with-pgp-signatures.html . If you have multiple private keys listed when running `gpg --list-secret-keys`, you need to export the one you chose for signing the Sonatype artifacts only! This could be done with (see https://unix.stackexchange.com/questions/481939/how-to-export-a-gpg-private-key-and-public-key-to-a-file):\n\n```shell\ngpg --output private.pgp --armor --export-secret-key username@email\n```\n\nNow fill the contents of the newly exported `private.pgp` into the GitHub repository secret named `MAVEN_GPG_PRIVATE_KEY`.\n\n\n### Complete the GitHub Action release workflow\n\nNow as the docs state, we can use the pre-configured `settings.xml` from the `setup-java` action to do the Maven release (see https://github.com/actions/setup-java). Depending on your `pom.xml`'s `distributionManagement` section we need to configure the `server-id`. [In my example project](https://github.com/codecentric/cxf-spring-boot-starter/blob/master/pom.xml) this is `oss.sonatype.org`:\n\n```xml\n\t\u003cdistributionManagement\u003e\n\t   \u003crepository\u003e\n\t     \u003cid\u003eoss.sonatype.org\u003c/id\u003e\n\t     \u003curl\u003ehttps://oss.sonatype.org/service/local/staging/deploy/maven2/\u003c/url\u003e\n\t   \u003c/repository\u003e\n\t   \u003csnapshotRepository\u003e\n\t     \u003cid\u003eoss.sonatype.org\u003c/id\u003e\n\t     \u003curl\u003ehttps://oss.sonatype.org/content/repositories/snapshots\u003c/url\u003e\n\t   \u003c/snapshotRepository\u003e\n\t\u003c/distributionManagement\u003e\n```\n\nNow let's complete the `release-to-maven-central.yml` GitHub Actions workflow file:\n\n```yaml\nname: release-to-maven-central\non:\n  workflow_dispatch:\n    inputs:\n      releaseversion:\n        description: 'Release version'\n        required: true\n        default: '2.4.0'\njobs:\n  publish:\n    runs-on: ubuntu-latest\n    steps:\n      - run: echo \"Will start a Maven Central upload with version ${{ github.event.inputs.releaseversion }}\"\n\n      - uses: actions/checkout@v2\n\n      - name: Set up Maven Central Repository\n        uses: actions/setup-java@v1\n        with:\n          java-version: 11\n          server-id: oss.sonatype.org\n          server-username: MAVEN_USERNAME\n          server-password: MAVEN_PASSWORD\n          gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}\n          gpg-passphrase: MAVEN_GPG_PASSPHRASE\n\n      - name: Set projects Maven version to GitHub Action GUI set version\n        run: mvn versions:set \"-DnewVersion=${{ github.event.inputs.releaseversion }}\"\n\n      - name: Publish package\n        run: mvn --batch-mode clean deploy -P central-deploy -DskipTests=true\n        env:\n          MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }}\n          MAVEN_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }}\n          MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}\n```\n\nAfter configuring the pre-configured `settings.xml`, we set the version number we set in the GitHub actions GUI to our Maven project with the help of the Maven versions plugin. Then we finally deploy our application to Maven Central.\n\n\n### Tackling the 'gpg: signing failed: Inappropriate ioctl for device' error\n\nYou may be running into the `gpg: signing failed: Inappropriate ioctl for device` error ([see this build](https://github.com/codecentric/cxf-spring-boot-starter/runs/1670320855?check_suite_focus=true)). No worries, we simply need to configure the `maven-gpg-plugin` inside our [pom.xml](https://github.com/codecentric/cxf-spring-boot-starter/blob/master/pom.xml). Just add the following `gpgArguments` configuration using the `--pinentry-mode` parameter:\n\n```xml\n\u003cplugin\u003e\n\t\u003cartifactId\u003emaven-gpg-plugin\u003c/artifactId\u003e\n\t\u003cversion\u003e${maven-gpg-plugin.version}\u003c/version\u003e\n\t\u003cexecutions\u003e\n\t  \u003cexecution\u003e\n\t    \u003cid\u003esign-artifacts\u003c/id\u003e\n\t    \u003cphase\u003everify\u003c/phase\u003e\n\t    \u003cgoals\u003e\n\t      \u003cgoal\u003esign\u003c/goal\u003e\n\t    \u003c/goals\u003e\n\t\t\u003cconfiguration\u003e\n\t\t  \u003c!-- This is necessary for gpg to not try to use the pinentry programs --\u003e\n\t\t  \u003cgpgArguments\u003e\n\t\t\t  \u003carg\u003e--pinentry-mode\u003c/arg\u003e\n\t\t\t  \u003carg\u003eloopback\u003c/arg\u003e\n\t\t  \u003c/gpgArguments\u003e\n\t\t\u003c/configuration\u003e\n\t  \u003c/execution\u003e\n\t\u003c/executions\u003e\n\u003c/plugin\u003e\n```\n\nHere's a [full successful Maven Central Release GitHub Actions build log](https://github.com/codecentric/cxf-spring-boot-starter/runs/1690791234?check_suite_focus=true).\n\nIf you have a look at Maven Central you should find the newly released artifact also (this could take some time though due to synchronisation issues):\n\n![maven-central-release-successful](screenshots/maven-central-release-successful.png)\n\n\n\n# Create a GitHub Release with every Maven Central Release\n\nAs we're now able to automatically create Maven Central releases of our project with GitHub Actions it would be also nice to have a GitHub Release on our repositories frontpage containing the newly released `jar` file.\n\nThere are multiple release actions out there. I tried to start with the GitHub default [create-release](https://github.com/marketplace/actions/create-a-release) action, which should create a new release for us. Now let's enhance our `release-to-maven-central.yml`:\n\n```yaml\n      - name: Create GitHub Release\n        id: create_release\n        uses: actions/create-release@v1\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        with:\n          tag_name: ${{ github.event.inputs.releaseversion }}\n          release_name: ${{ github.event.inputs.releaseversion }}\n          body: |\n            Grab the new version from Maven central https://repo1.maven.org/maven2/de/codecentric/cxf-spring-boot-starter/${{ github.event.inputs.releaseversion }}/ by using it in your deps (also use the newest cxf-spring-boot-starter-maven-plugin https://github.com/codecentric/cxf-spring-boot-starter-maven-plugin):\n\n            ```\n            \u003cdependencies\u003e\n            \t\u003cdependency\u003e\n            \t    \u003cgroupId\u003ede.codecentric\u003c/groupId\u003e\n            \t    \u003cartifactId\u003ecxf-spring-boot-starter\u003c/artifactId\u003e\n            \t    \u003cversion\u003e${{ github.event.inputs.releaseversion }}\u003c/version\u003e\n            \t\u003c/dependency\u003e\n            \u003c/dependencies\u003e\n            ```\n          draft: false\n          prerelease: false\n```\n\nThe `release_name` and `tag_name` use the version number we define through the GitHub Actions workflow UI. The action also creates a git tag inside our repo for us - so no need to do this ourselves. Inside the body we add a description of where our newly released `jar` can be downloaded from (Maven Central) and how to embed it into your project.\n\n### Extending the GitHub release with a changelog\n\nIt would be really nice to also have a changelog present in the GitHub release. There are multiple actions again that generate changelogs for us automatically. I you're looking for a really simple one, that only lists the commits that are new inside this release compared to the last one, then you'd might have a look at https://github.com/metcalfc/changelog-generator It's usage is really straight forward. Before our `create-release` phase, we add it to generate the changelog:\n\n```yaml\n- name: Generate changelog\n  id: changelog\n  uses: metcalfc/changelog-generator@v0.4.4\n  with:\n    myToken: ${{ secrets.GITHUB_TOKEN }}\n```\n\nAnd then we use the generated changelog inside our `create-release` step:\n\n```yaml\n      - name: Create GitHub Release\n        id: create_release\n        uses: actions/create-release@v1\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        with:\n          tag_name: ${{ github.event.inputs.releaseversion }}\n          release_name: ${{ github.event.inputs.releaseversion }}\n          body: |\n            Grab the new version from Maven central https://repo1.maven.org/maven2/de/codecentric/cxf-spring-boot-starter/${{ github.event.inputs.releaseversion }}/ by using it in your deps (also use the newest cxf-spring-boot-starter-maven-plugin https://github.com/codecentric/cxf-spring-boot-starter-maven-plugin):\n\n            ```\n            \u003cdependencies\u003e\n            \t\u003cdependency\u003e\n            \t    \u003cgroupId\u003ede.codecentric\u003c/groupId\u003e\n            \t    \u003cartifactId\u003ecxf-spring-boot-starter\u003c/artifactId\u003e\n            \t    \u003cversion\u003e${{ github.event.inputs.releaseversion }}\u003c/version\u003e\n            \t\u003c/dependency\u003e\n            \u003c/dependencies\u003e\n            ```\n\n            ### Things that changed in this release\n            ${{ steps.changelog.outputs.changelog }}\n          draft: false\n          prerelease: false\n```\n\nNow after a new `release-to-maven-central` workflow run, we should see a new release on our repositories frontpage:\n\n![github-release](screenshots/github-release.png)\n\nAnd clicking into the very details of this release, we should see a customized download advice to our released jar - together with a nice changelog list:\n\n![github-release-commitlog](screenshots/github-release-commitlog.png)\n\n\n# Publish SNAPSHOT versions to GitHub Packages\n\nWe can also [publish our Maven artifacts to GitHub Packages](https://docs.github.com/en/free-pro-team@latest/actions/guides/publishing-java-packages-with-maven#publishing-packages-to-github-packages). As we might want to also have our `SNAPSHOT` versions available to the public, we could use GitHub Packages for the SNAPSHOTs and Maven Central for the release versions.\n\nTherefore we need to enhance our workflows a little more. First we need to add GitHub Packages to our `pom.xml`s `distributionManagement` section. As we can't add 2 `repository` tags to `distributionManagement`, we simply use the `snapshotRepository` tag here for GitHub Packages:\n\n```xml\n    \u003cdistributionManagement\u003e\n        \u003crepository\u003e\n            \u003cid\u003eoss.sonatype.org\u003c/id\u003e\n            \u003curl\u003ehttps://oss.sonatype.org/service/local/staging/deploy/maven2/\u003c/url\u003e\n        \u003c/repository\u003e\n        \u003csnapshotRepository\u003e\n            \u003cid\u003egithub\u003c/id\u003e\n            \u003cname\u003eGitHub Packages\u003c/name\u003e\n            \u003curl\u003ehttps://maven.pkg.github.com/codecentric/cxf-spring-boot-starter\u003c/url\u003e\n        \u003c/snapshotRepository\u003e\n    \u003c/distributionManagement\u003e\n```\n\nAlso __mind the `url` of the GitHub Packages configuration__, since it __must match__ your GitHub organisation and repository like this: `https://maven.pkg.github.com/yourOrganisationHere/yourRepositoryNameHere`. Otherwise you'll run into errors like this:\n\n```shell\nCould not find artifact de.codecentric:cxf-spring-boot-starter:jar:2.4.0-20210112.171149-1 in github (https://maven.pkg.github.com/jonashackt/cxf-spring-boot-starter)\n```\n\nFurthermore I wanted to only start the `publish` job, if the `build` job with it's Matrix build of 3 Java versions was successfully done. Because if you simply concatenate the jobs, both jobs will be run in parallel (see [this build log for example](https://github.com/codecentric/cxf-spring-boot-starter/actions/runs/480285190)):\n\n![build-and-publish-jobs-parallel](screenshots/build-and-publish-jobs-parallel.png)\n\nWith GitHub Actions we have 2 options how to implement a sequence of jobs. The first possibility is to create a separate workflow in a separate yaml file and use the [the new](https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/) Actions [`workflow_run` event, which is documented in the docs](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#workflow_run) as:\n\n\u003e This event occurs when a workflow run is requested or completed, and allows you to execute a workflow based on the finished result of another workflow.\n\nAnd this event is similar to the `workflow_dispatch` event, which is only triggerable on the default branch (`master` at my example repo). The `workflow_run` event is configured to run, when another workflow ahs finished. I named the new workflow `publish-snapshot.yml`:\n\n```yaml\nname: publish-snapshot\n\n# Only trigger a SNAPSHOT release to GitHub Packages, when the build workflow succeeded\non:\n  workflow_run:\n    workflows: [\"build\"]\n    types:\n      - completed\n\njobs:\n  publish-snapshot:\n    runs-on: ubuntu-latest\n\n    steps:\n    - uses: actions/checkout@v2\n\n    - name: Set up settings.xml for GitHub Packages\n      uses: actions/setup-java@v1\n      with:\n        java-version: 1.8\n\n    - name: Publish SNAPSHOT version to GitHub Packages (we can skip tests, since we only deploy, if the build workflow succeeded)\n      run: mvn -B --no-transfer-progress deploy -DskipTests --projects cxf-spring-boot-starter\n      env:\n        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n```\n\nNow this workflow is only triggered, when our `build` workflow has successfully done it's Matrix build with 3 Java versions. I also added the ` -DskipTests` parameter, since this workflow doesn't need to run all tests again - because it's triggered by our `build` workflow, which already ran the tests. I also added `--projects cxf-spring-boot-starter` because I have a Maven multi module project - and only want to publish this module (and not the samples).\n\nThe second option is to use [the `needs` keyword inside a job definition](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idneeds). This is very elegant, since we can define  the sequence of Action jobs inside the same workflow file like this:\n\n```yaml\nname: build\n\non: [push]\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    strategy:\n      matrix:\n        java-version: [ 8, 11, 15 ]\n\n    steps:\n    - uses: actions/checkout@v2\n    - uses: actions/setup-java@v1\n      with:\n        java-version: ${{ matrix.java-version }}\n    - run: mvn -B install --no-transfer-progress --file pom.xml\n\n  publish-snapshot:\n    needs: build\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions/checkout@v2\n\n      - name: Set up settings.xml for GitHub Packages\n        uses: actions/setup-java@v1\n        with:\n          java-version: 1.8\n\n      - name: Publish SNAPSHOT version to GitHub Packages (we can skip tests, since we only deploy, if the build workflow succeeded)\n        run: mvn -B --no-transfer-progress deploy -DskipTests --projects cxf-spring-boot-starter\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n```\n\nAlso the Actions UI implements this quite nice because we see all depending jobs in one overview:\n\n![build-job-triggers-publish-job](screenshots/build-job-triggers-publish-job.png)\n\n\nAfter a successful `mvn deploy` to GitHub Packages, you should also see a new entry on the frontpage of your repository like this:\n\n![packages-listed](screenshots/packages-listed.png)\n\nAlso all your packages regardless which repository they were published from are listed on the organisational level. Just go to `https://github.com/orgs/yourOrganisationNameHere/packages`:\n\n![packages-list-organizational-level](screenshots/packages-list-organizational-level.png)\n\nThe [docs have even more detailled info on where your packages will be visible](https://docs.github.com/en/free-pro-team@latest/packages/manage-packages/viewing-packages).\n\n\n# Deploy to GitHub Pages\n\nThere's this nice action https://github.com/marketplace/actions/deploy-to-github-pages that easily deploys your let's say Asciidoctor generated docs to GitHub Pages. Add the following to your `workflow.yml`:\n\n```yaml\n      - name: Publish SNAPSHOT version to GitHub Packages (we can skip tests, since we only deploy, if the build workflow succeeded)\n        run: # run a build of your docs into the directory 'generated-docs' - there JamesIves/github-pages-deploy-action will pick it up\n\n      - name: Deploy Asciidoc docs output to GitHub Pages\n        uses: JamesIves/github-pages-deploy-action@3.7.1\n        with:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          BRANCH: gh-pages # The branch the action should deploy to.\n          FOLDER: generated-docs # The folder the action should deploy.\n          CLEAN: true # Automatically remove deleted files from the deploy branch\n```\n\n\nIf you want to use the Maven `pom.xml`'s current version number, here's an example that uses GitHub Actions [`set-output` variable definition](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter) to define the version number later used in the Pages deployment Action:\n\n\n```yaml\n      - name: Publish SNAPSHOT version to GitHub Packages (we can skip tests, since we only deploy, if the build workflow succeeded)\n        run: mvn -B --no-transfer-progress package --projects your-asciidoc-containing-maven-module -DskipTests\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n\n      - name: Extract Maven project version for Asciidoc GitHub Pages directory naming\n        run: echo ::set-output name=version::$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)\n        id: project\n\n      - name: Show extracted Maven project version\n        run: echo ${{ steps.project.outputs.version }}\n\n      - name: Deploy Asciidoc docs output to GitHub Pages\n        uses: JamesIves/github-pages-deploy-action@3.7.1\n        with:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          BRANCH: gh-pages # The branch the action should deploy to.\n          FOLDER: your-asciidoc-containing-maven-module/target/generated-docs # The folder the action should deploy.\n          TARGET_FOLDER: ${{ steps.project.outputs.version }}\n          CLEAN: true # Automatically remove deleted files from the deploy branch\n```\n\nSee it in action here: https://github.com/codecentric/spring-boot-admin\n\n\n\n# Add Coverage reports using codecov.io\n\nIf you want to add coverage reports to your repository - for example using https://coveralls.io - then you first need to add an appropriate Plugin to generate the test reports like `jacoco-maven-plugin``. \n\nI really liked coveralls.io and was using it in many of my OpenSource projects. But sadly the safd doesn't support JaCoCo/Java out-of-the-box atm (see this issue: https://github.com/coverallsapp/github-action/issues/22) and there's no roadmap if it's going to be supported in the near future.\n\nLooking at the cucumber-jvm team I found that they just switched over to https://about.codecov.io/ - so let's do that also!\n\nAs we want to create a separate GitHub Actions Job for the Coverage reports, it would be also great to have the coveralls configuration inside a separate Maven profile inside our `pom.xml` like this:\n\n```xml\n        \u003cprofile\u003e\n            \u003cid\u003ecoverage\u003c/id\u003e\n            \u003cbuild\u003e\n                \u003cplugins\u003e\n                    \u003cplugin\u003e\n                        \u003cgroupId\u003eorg.jacoco\u003c/groupId\u003e\n                        \u003cartifactId\u003ejacoco-maven-plugin\u003c/artifactId\u003e\n                        \u003cversion\u003e${build-plugin.jacoco.version}\u003c/version\u003e\n                        \u003cexecutions\u003e\n                            \u003c!-- Prepares the property pointing to the JaCoCo\n                            runtime agent which is passed as VM argument when Maven the Surefire plugin\n                            is executed. --\u003e\n                            \u003cexecution\u003e\n                                \u003cid\u003epre-unit-test\u003c/id\u003e\n                                \u003cgoals\u003e\n                                    \u003cgoal\u003eprepare-agent\u003c/goal\u003e\n                                \u003c/goals\u003e\n                            \u003c/execution\u003e\n                            \u003c!-- Ensures that the code coverage report for\n                            unit tests is created after unit tests have been run. --\u003e\n                            \u003cexecution\u003e\n                                \u003cid\u003epost-unit-test\u003c/id\u003e\n                                \u003cphase\u003etest\u003c/phase\u003e\n                                \u003cgoals\u003e\n                                    \u003cgoal\u003ereport\u003c/goal\u003e\n                                \u003c/goals\u003e\n                            \u003c/execution\u003e\n                        \u003c/executions\u003e\n                    \u003c/plugin\u003e\n                \u003c/plugins\u003e\n            \u003c/build\u003e\n        \u003c/profile\u003e\n```\n\nNow we can create a new GitHub Actions job inside our `build.yml` workflow using the codecov action: https://github.com/codecov/codecov-action\n\n```yaml\n  coverage:\n    needs: build\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions/checkout@v2\n      - uses: actions/setup-java@v1\n        with:\n          java-version: 15\n      - run: mvn -B test -P coverage --no-transfer-progress\n\n      - uses: codecov/codecov-action@v1\n        with:\n          file: ./**/target/site/jacoco/jacoco.xml\n          name: codecov\n```\n\nWe only use one Java version here (`15` - since the coverage report should be the same throughout all Java versions). And we explicitely use our `coverage` Maven Profile here specifying it with `mvn -B test -P coverage`. \n\nBe sure to also add the repository to your codegov orga:\n\n![codegov-add-repo](screenshots/codegov-add-repo.png)\n\nAnd finally don't forget to add a nice badge to your repo's README like that:\n\n```markdown\n[![codecov](https://codecov.io/gh/codecentric/cxf-spring-boot-starter/branch/master/graph/badge.svg?token=Ntc7Kn0qXz)](https://codecov.io/gh/codecentric/cxf-spring-boot-starter)\n```\n\nYou can find the generated badges for you in codegov at https://app.codecov.io/gh/yourOrga/yourRepository/settings/badge\n\n\n### Links\n\nSee manual guide in https://gist.github.com/jonashackt/a09fa064145ff5620c19bc05080378e8\n\nhttps://github.com/marketplace/actions/create-a-release\n\nhttps://github.com/marketplace/actions/upload-a-release-asset","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonashackt%2Fgithub-actions-release-maven","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonashackt%2Fgithub-actions-release-maven","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonashackt%2Fgithub-actions-release-maven/lists"}