With the addition of the workflow_dispatch event, you can now create workflows on GitHub Actions that are manually triggered. Also, you can specify inputs, which GitHub will present as form elements in the UI. This is particularly useful when cutting releases with Maven.
- Create a new workflow containing two input fields:
releaseVersion
and developmentVersion
.
on:
workflow_dispatch:
inputs:
releaseVersion:
description: "Default version to use when preparing a release."
required: true
default: "X.Y.Z"
developmentVersion:
description: "Default version to use for new local working copy."
required: true
default: "X.Y.Z-SNAPSHOT"
- Set up a job to make Maven releases using the given
releaseVersion
and developmentVersion
.
jobs:
release:
runs-on: ubuntu-latest
steps:
# Checkout source code, set up Java, etc. Then...
- name: Configure Git User
run: |
git config user.email "actions@github.com"
git config user.name "GitHub Actions"
- name: Maven Release
run: mvn release:prepare release:perform -B -s .maven_settings.xml -DreleaseVersion=${{ github.event.inputs.releaseVersion }} -DdevelopmentVersion=${{ github.event.inputs.developmentVersion }}
env:
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
You must have a .maven_settings.xml
file saved at the root of your project, containing the username
and password
to authenticate before downloading or uploading artifacts to repositories configured in the repositories
and distributionManagement
sections.
<settings>
...
<servers>
<server>
<id>server.id</id>
<username>${env.CI_DEPLOY_USERNAME}</username>
<password>${env.CI_DEPLOY_PASSWORD}</password>
</server>
</servers>
</settings>
You can configure both secrets CI_DEPLOY_USERNAME
and CI_DEPLOY_PASSWORD
on the project's settings page.
Here's a full example of a Maven release workflow configuration for reference.