feat: add java spotless code formatter #106
Workflow file for this run
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: Release Version | |
on: | |
workflow_dispatch: | |
pull_request_target: | |
types: | |
- closed | |
branches: | |
- 'main' | |
push: | |
branches: | |
- 'main' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
name: Deploy release | |
environment: staging | |
# only trigger the workflow on the base repository and if the merged branch name starts with release. | |
if: (github.repository_owner == 'RHEcosystemAppEng' && github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') ) || (github.repository_owner == 'RHEcosystemAppEng' && github.ref_name == 'main' && contains(github.event.commits[0].message, 'release/directly')) | |
outputs: | |
project_version: ${{ steps.project.outputs.version }} | |
last_release_tag: ${{ steps.last-release.outputs.tag-name }} | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
with: | |
ssh-key: ${{ secrets.DEPLOY_KEY }} | |
fetch-depth: 0 | |
- name: Setup Java 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: 11 | |
cache: maven | |
- name: create ssh agent | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.DEPLOY_KEY }} | |
- name: Configure git | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
- name: get previous released annotated tag | |
id: last-release | |
run: | | |
echo "tag-name=$(git describe | awk -F '-' '{print $1}')" >> "$GITHUB_OUTPUT" | |
- name: Deploy release to GitHub | |
run: | | |
mvn release:prepare release:perform -B -ff | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get pom version of released artifact | |
id: project | |
run: | | |
git checkout HEAD^ pom.xml | |
echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> "$GITHUB_OUTPUT" | |
git restore pom.xml --staged --worktree | |
release: | |
runs-on: ubuntu-latest | |
name: Release | |
if: (github.repository_owner == 'RHEcosystemAppEng' && startsWith(github.head_ref, 'release/')) || (github.repository_owner == 'RHEcosystemAppEng' && github.ref_name == 'main' && contains(github.event.commits[0].message, 'release/directly')) | |
environment: staging | |
needs: deploy | |
steps: | |
- name: Create release notes for ${{ needs.deploy.outputs.project_version }} release | |
uses: actions/github-script@v6 | |
id: release-notes | |
with: | |
github-token: ${{ secrets.STAGING_PAT }} | |
script: | | |
const repo_name = context.payload.repository.full_name | |
const response = await github.request('POST /repos/' + repo_name + '/releases' + '/generate-notes', { | |
tag_name: '${{ needs.deploy.outputs.project_version }}', | |
previous_tag_name: '${{ needs.deploy.outputs.last_release_tag }}' | |
}) | |
return response.data.body | |
- name: Create new ${{ needs.deploy.outputs.project_version }} release | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.STAGING_PAT }} | |
script: | | |
const repo_name = context.payload.repository.full_name | |
const response = await github.request('POST /repos/' + repo_name + '/releases', { | |
tag_name: '${{ needs.deploy.outputs.project_version }}', | |
name: '${{ needs.deploy.outputs.project_version }}', | |
body: ${{ steps.release-notes.outputs.result }}, | |
draft: false, | |
prerelease: false, | |
make_latest: 'true' | |
}) | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
with: | |
ssh-key: ${{ secrets.DEPLOY_KEY }} | |
fetch-depth: 0 | |
- name: Configure git | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
- name: Get pom version of new snapshot artifact | |
id: project_snapshot | |
run: | | |
git pull | |
echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> "$GITHUB_OUTPUT" | |
- name: Update readme usage section | |
run: > | |
sed -i | |
's/<version>.*<\/version>/<version>${{ steps.project_snapshot.outputs.version }}<\/version>/g' | |
README.md | |
- name: Push modifications | |
run: | | |
git add README.md | |
git commit -m "docs: updated usage section with version ${{ steps.project_snapshot.outputs.version }} [skip ci]" | |
git push |