├── README.md ├── settings.xml ├── action.yaml └── run.sh /README.md: -------------------------------------------------------------------------------- 1 | Deploys a Maven project to the Jenkins Artifactory repository in continuous delivery style. 2 | Also publishes a release if one is currently drafted under the name `next`. 3 | Used by [JEP-229](https://jenkins.io/jep/229). 4 | -------------------------------------------------------------------------------- /settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | maven.jenkins-ci.org 6 | 7 | 8 | 9 | Authorization 10 | Bearer ${env.MAVEN_TOKEN} 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /action.yaml: -------------------------------------------------------------------------------- 1 | name: jenkins-maven-cd 2 | description: Deploys a Maven project to the Jenkins Artifactory repository in continuous delivery style. 3 | inputs: 4 | GITHUB_TOKEN: 5 | required: true 6 | description: Token to run with, defaults to the repository GITHUB_TOKEN 7 | MAVEN_USERNAME: 8 | required: true 9 | description: Maven username used for deploying the plugin jar to Jenkins Artifactory Repository 10 | MAVEN_TOKEN: 11 | required: true 12 | description: Maven token used for deploying the plugin jar to Jenkins Artifactory Repository 13 | INTERESTING_CATEGORIES: 14 | required: true 15 | description: | 16 | Regexp of emojis from https://github.com/jenkinsci/.github/blob/master/.github/release-drafter.yml representing changes of interest to users. 17 | By default excludes 📦📝👻🚦 under the assumption these do not normally merit a release. 18 | Ignored when using workflow_dispatch (explicit release); when using the check_run trigger (automatic), the release is skipped unless the draft changelog matches. 19 | default: '[💥🚨🎉🐛⚠🚀🌐👷]|:(boom|tada|construction_worker):' 20 | runs: 21 | using: composite 22 | steps: 23 | - run: $GITHUB_ACTION_PATH/run.sh 24 | shell: bash 25 | env: 26 | GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} 27 | MAVEN_USERNAME: ${{ inputs.MAVEN_USERNAME }} 28 | MAVEN_TOKEN: ${{ inputs.MAVEN_TOKEN }} 29 | INTERESTING_CATEGORIES: ${{ inputs.INTERESTING_CATEGORIES }} 30 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euxo pipefail 3 | if [ $GITHUB_EVENT_NAME = check_run ] 4 | then 5 | gh api /repos/$GITHUB_REPOSITORY/releases | jq -e -r '[ .[] | select(.draft == true and .name == "next")] | max_by(.id).body' | egrep "$INTERESTING_CATEGORIES" 6 | fi 7 | export MAVEN_OPTS=-Djansi.force=true 8 | # deployAtEnd defaults to 'true' with Maven 4.x 9 | mvn -B -V -e -s $GITHUB_ACTION_PATH/settings.xml -ntp -Dstyle.color=always -Dset.changelist -DaltDeploymentRepository=maven.jenkins-ci.org::https://repo.jenkins-ci.org/releases/ -Pquick-build -P\!consume-incrementals clean deploy -DdeployAtEnd=true -DretryFailedDeploymentCount=2 10 | version=$(mvn -B -ntp -Dset.changelist -Dexpression=project.version -q -DforceStdout help:evaluate) 11 | # Create the annotated git tag - https://docs.github.com/en/rest/git/tags#create-a-tag-object 12 | gh api -F tag=$version -F message=$version -F object=$GITHUB_SHA -F type=commit /repos/$GITHUB_REPOSITORY/git/tags 13 | # Create the git reference associated to the annotated git tag - https://docs.github.com/en/rest/git/refs#create-a-reference 14 | gh api -F ref=refs/tags/$version -F sha=$GITHUB_SHA /repos/$GITHUB_REPOSITORY/git/refs 15 | # Publish the GitHub draft release and associate it with the git tag - https://docs.github.com/en/rest/releases/releases#update-a-release 16 | release=$(gh api /repos/$GITHUB_REPOSITORY/releases | jq -e -r '[ .[] | select(.draft == true and .name == "next").id] | max') 17 | gh api -X PATCH -F draft=false -F name=$version -F tag_name=$version /repos/$GITHUB_REPOSITORY/releases/$release 18 | --------------------------------------------------------------------------------