Delete .github/workflows/code-maven_java-QA_compatibility.yml #23
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: code-release-preview | |
concurrency: | |
group: release-preview | |
cancel-in-progress: true | |
on: | |
pull_request: | |
types: [labeled, synchronize, ready_for_review, opened] | |
branches: ['main', 'main-*'] | |
env: | |
PR_HEAD_REF: ${{ github.head_ref }} | |
jobs: | |
check-changes-in-paths: | |
name: Check for changes in corresponding paths | |
runs-on: ubuntu-20.04 | |
if: ${{ github.event.pull_request.draft == false || contains(join(github.event.pull_request.labels.*.name, ', '), 'release-type') || contains(join(github.event.pull_request.labels.*.name, ', '), 'release-preview') }} | |
outputs: | |
detected: ${{ steps.changes.outputs.paths }} | |
steps: | |
- name: Check for changed files in specific paths | |
id: changes | |
uses: dorny/paths-filter@ebc4d7e9ebcb0b1eb21480bb8f43113e996ac77a | |
with: | |
filters: | | |
paths: | |
- 'code/**' | |
- '.github/workflows/code*' | |
release-preview: | |
name: Release Preview | |
needs: check-changes-in-paths | |
if: ${{ (contains(join(github.event.pull_request.labels.*.name, ', '), 'release-type') || contains(join(github.event.pull_request.labels.*.name, ', '), 'release-preview')) && needs.check-changes-in-paths.outputs.detected == 'true' }} | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout merge commit | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Setup Maven Cache | |
uses: actions/cache@v4 | |
continue-on-error: true | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Setup asdf Cache | |
uses: actions/cache@v4 | |
continue-on-error: true | |
with: | |
path: ~/.asdf/data | |
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }} | |
restore-keys: | | |
${{ runner.os }}-asdf- | |
- name: Save tool-versions content | |
run: | | |
{ | |
echo "TOOL_VERSIONS<<EOF" | |
cat code/.tool-versions | |
echo "EOF" | |
} >> "$GITHUB_ENV" | |
- name: Setup asdf environment | |
uses: asdf-vm/actions/install@v3 | |
with: | |
tool_versions: ${{ env.TOOL_VERSIONS }} | |
- name: Setup Java environment vars | |
run: | | |
JAVA_HOME="$(asdf where java)" | |
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV | |
- name: Setup hotfix release type version and simulate merge | |
if: ${{ contains(github.event.pull_request.labels.*.name, 'release-type/hotfix') }} | |
run: echo "RELEASE_VERSION=patch" >> "$GITHUB_ENV" | |
- name: Setup multi-hotfix release type version | |
if: contains(github.event.pull_request.labels.*.name, 'release-type/multi-hotfix') | |
run: echo "RELEASE_VERSION=patch" >> "$GITHUB_ENV" | |
- name: Setup patch release type version | |
if: contains(github.event.pull_request.labels.*.name, 'release-type/patch') | |
run: echo "RELEASE_VERSION=patch" >> "$GITHUB_ENV" | |
- name: Setup minor release type version | |
if: contains(github.event.pull_request.labels.*.name, 'release-type/minor') | |
run: echo "RELEASE_VERSION=minor" >> "$GITHUB_ENV" | |
- name: Setup major release type version | |
if: contains(github.event.pull_request.labels.*.name, 'release-type/major') | |
run: echo "RELEASE_VERSION=major" >> "$GITHUB_ENV" | |
- name: Check merge strategy | |
run: | | |
if [[ "$PR_HEAD_REF" == hotfix* && "${{ contains(github.event.pull_request.labels.*.name, 'release-type/multi-hotfix') }}" != "true" ]] ; | |
then | |
echo "MERGE_STRATEGY=Squash and Merge" >> "$GITHUB_ENV" | |
elif [[ "${{vars.DEVELOPMENT_FLOW}}" == 'trunk-based-development' && ("$PR_HEAD_REF" == hotfix* && "${{ contains(github.event.pull_request.labels.*.name, 'release-type/multi-hotfix') }}" == "true") ]] ; | |
then | |
echo "MERGE_STRATEGY=Create a merge commit" >> "$GITHUB_ENV" | |
elif [[ "${{ vars.DEVELOPMENT_FLOW }}" == 'trunk-based-development' ]] ; | |
then | |
echo "MERGE_STRATEGY=Squash and Merge" >> "$GITHUB_ENV" | |
else | |
echo "MERGE_STRATEGY=Create a merge commit" >> "$GITHUB_ENV" | |
fi | |
- name: Check if CHANGELOG.md has changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
if git diff --quiet HEAD^ HEAD -- code/CHANGELOG.md; then | |
echo "::error title={No CHANGELOG.md changes}::{No CHANGELOG.md changes were found. Update the UNRELEASED section with the new changes.}" | |
gh pr comment ${{ github.event.number }} --body " | |
### :x: No changes in the \`CHANGELOG.md\` file | |
No changes were found in the \`CHANGELOG.md\` file. Please, update the UNRELEASED section, listing the new changes that applies to this release." | |
exit 1 | |
fi | |
- name: Update CHANGELOG.md | |
id: update-changelog | |
uses: release-flow/[email protected] | |
with: | |
command: bump | |
version: ${{ env.RELEASE_VERSION }} | |
changelog: code/CHANGELOG.md | |
fail-on-empty-release-notes: false | |
keep-unreleased-section: true | |
tag-prefix: "" | |
- name: Add PR comment with release preview | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
TASKS=$(awk -v version="${{ steps.update-changelog.outputs.version }}" ' | |
BEGIN { capture=0; found_version=0 } | |
$0 ~ "## \\[" version "\\] -" { capture=1; found_version=1; print; next } | |
capture && $0 ~ /^## \[.*\] -/ { capture=0 } | |
capture { print } | |
END { | |
if (found_version) { | |
while ((getline line < "code/CHANGELOG.md") > 0) { | |
if (line ~ /^\[.*\]:/) { | |
print line | |
} | |
} | |
} | |
} | |
' code/CHANGELOG.md) | |
MESSAGE=" | |
### :rocket: Release Preview Success | |
You are going to release the version **${RELEASE_VERSION}** with the following changes: | |
$TASKS | |
### 💡 Merge Strategy: $MERGE_STRATEGY | |
Remember to use the **'$MERGE_STRATEGY'** strategy to merge this _Pull Request (\`$PR_HEAD_REF\` → \`${{ github.event.pull_request.base.ref }}\`)_. | |
" | |
gh pr comment ${{ github.event.number }} --body "$(echo -e "$MESSAGE")" | |
release-preview-no-code-changes: | |
name: Add PR comment with configuration management information | |
needs: check-changes-in-paths | |
if: ${{ (contains(join(github.event.pull_request.labels.*.name, ', '), 'release-type') || (contains(join(github.event.pull_request.labels.*.name, ', '), 'release-preview'))) && needs.check-changes-in-paths.outputs.detected == 'false' }} | |
runs-on: ubuntu-20.04 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout merge commit | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Add PR comment with release preview | |
run: | | |
BODY=" | |
### :exclamation: :exclamation: :exclamation: This Pull Request will not trigger a Release | |
A Pull Request with no changes to the \`code/\` folder will not trigger a release" | |
gh pr comment ${{ github.event.number }} --body "$BODY" | |
release-preview-no-release-labels: | |
name: Add PR comment with release information | |
needs: check-changes-in-paths | |
if: ${{ !contains(join(github.event.pull_request.labels.*.name, ', '), 'release-type') && needs.check-changes-in-paths.outputs.detected == 'true' && github.event.pull_request.draft == false && vars.DEVELOPMENT_FLOW != 'trunk-based-development' }} | |
runs-on: ubuntu-20.04 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout merge commit | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Add PR comment with release preview | |
run: | | |
gh pr comment ${{ github.event.number }} --body " | |
### :exclamation: :exclamation: :exclamation: This Pull Request will not trigger a Release | |
A Pull Request with no \`release-type/...\` labels will not trigger a release, so you need to label this PR if you want to create a release. | |
" |