chore(deps): update dependency com.github.gantsign.maven:ktlint-maven… #255
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: | |
push: | |
branches: | |
- "**" | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
get-runner-user: | |
runs-on: ubuntu-22.04 | |
outputs: | |
uid_gid: ${{ steps.get-user.outputs.uid_gid }} | |
steps: | |
- id: get-user | |
run: echo "uid_gid=$(id -u):$(id -g)" >> "$GITHUB_OUTPUT" | |
build-and-deploy: | |
needs: get-runner-user | |
runs-on: ubuntu-22.04 | |
container: | |
image: "public.ecr.aws/z8l5l4v4/buildtools/tool/maven:3-jdk-11-alpine" | |
options: --user ${{ needs.get-runner-user.outputs.uid_gid }} | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
with: | |
path: ~/.m2/repository | |
key: maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: maven- | |
- name: store branch name in environment | |
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF##*/})" >> "$GITHUB_ENV" | |
- name: git config | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
- name: configure maven | |
run: | | |
mkdir -p "$HOME/.m2" | |
cat <<EOF > "$HOME/.m2/settings.xml" | |
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd"> | |
<servers> | |
<server> | |
<id>github</id> | |
<username>\${env.GITHUB_ACTOR}</username> | |
<password>\${env.GITHUB_TOKEN}</password> | |
</server> | |
</servers> | |
</settings> | |
EOF | |
- name: conditional release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
export MAVEN_OPTS="-Duser.home=$HOME" # Home directory not automatically picked up for some reason | |
major_version="$(sed -n "s/^.*<major-version>\([0-9]\{1,\}\)<\/major-version>.*$/\1/p" pom.xml)" | |
date="$(date -u "+%Y%m%d.%H%M%S")" | |
tag="$major_version.$date" | |
printf "Tag to use for potential release: %s\n" "$tag" | |
mvn -B org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce -Drules=requireReleaseDeps | |
release="false" | |
git fetch --tags | |
if [ "$BRANCH_NAME" = "master" ]; then | |
latest_tag="$(git describe --abbrev=0 || true)" | |
latest_tag_commit="$(if test -n "$latest_tag"; then git rev-parse "$latest_tag^{}"; fi)" | |
if [ ! "$latest_tag_commit" = "$GITHUB_SHA" ]; then | |
release="true" | |
fi | |
fi | |
if [ "$release" = "true" ]; then | |
# Release to GitHub Packages | |
mvn -B source:jar deploy -DaltReleaseDeploymentRepository="github::default::https://maven.pkg.github.com/capralifecycle/snapshot-test" -Drevision="$tag" -Dtag="$tag" | |
else | |
mvn -B source:jar verify -Drevision="$tag" -Dtag="$tag" | |
fi |