Skip to content

Commit

Permalink
update github action
Browse files Browse the repository at this point in the history
  • Loading branch information
chensoul committed Dec 7, 2023
1 parent 390f88f commit 7aa309d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# https://github.com/marketplace/actions/release-changelog-builder
name: 'Github Release'
run-name: 'Github Release'

on:
repository_dispatch:
types: [release-notes]
types: [github-release]

concurrency:
group: ${{ github.event.pull_request.number }}-ci
cancel-in-progress: true

jobs:
release-notes:
build:
if: github.event.client_payload.auto_release == 'true'
runs-on: ubuntu-latest
steps:
Expand All @@ -29,7 +30,6 @@ jobs:
https://api.github.com/repos/${{github.event.repository.owner.login}}/${{github.event.repository.name}}/releases/latest | jq -r '.tag_name')" >> $GITHUB_ENV
echo "currentTag=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v2
with:
configuration: ".github/configs/configuration_repo.json"
Expand All @@ -43,7 +43,6 @@ jobs:
body: ${{steps.github_release.outputs.changelog}}
tag_name: ${{env.currentTag}}
- name: Artifact Information
id: artifact_information
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
Expand Down
31 changes: 19 additions & 12 deletions .github/workflows/maven-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
description: "Define the SNAPSHOT version"
required: false
default: ""
autoReleaseAfterClose:
description: "Auto release after close"
required: false
default: "false"

jobs:
build:
Expand Down Expand Up @@ -39,18 +43,26 @@ jobs:
shell: bash
run: |
if [ "${{ github.event.inputs.releaseVersion }}" != "" ] && [ "${{ github.event.inputs.developmentVersion }}" != "" ]; then
echo "auto_version=false" >> $GITHUB_ENV
else
echo "auto_version=true" >> $GITHUB_ENV
fi
if [ "${{ github.event.inputs.autoReleaseAfterClose }}" == "true" ] ; then
echo "auto_release=true" >> $GITHUB_ENV
else
echo "auto_release=false" >> $GITHUB_ENV
fi
- name: Artifact Version
- name: Fetch Artifact Information
shell: bash
run: |
# remove '-SNAPSHOT'
echo "artifact_version=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT$//')" >> "$GITHUB_ENV"
echo "artifact_name=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> "$GITHUB_ENV"
echo "artifact_packaging=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.packaging -q -DforceStdout)" >> "$GITHUB_ENV"
echo "${{ env.artifact_name }} ${{ env.artifact_version }} ${{ env.artifact_packaging }}"
- name: Release With Maven
run: |
if [ "${{ env.auto_release }}" == "true" ]; then
if [ "${{ env.auto_version }}" == "true" ]; then
mvn -B -U \
release:prepare \
release:perform \
Expand All @@ -69,23 +81,18 @@ jobs:
-Prelease \
-Dgpg.passphrase=${{ secrets.MAVEN_GPG_PASSPHRASE }}
fi
ls -al ./target/
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
- name: Artifact Name
shell: bash
run: |
echo "artifact_name=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> "$GITHUB_ENV"
echo "${{ env.artifact_name }} ${{ env.artifact_version }}"
ls -al ./target/
AUTO_RELEASE_AFTER_CLOSE: ${{ env.auto_release }}
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.artifact_name }}-${{ env.artifact_version }}
path: ./target/${{ env.artifact_name }}-${{ env.artifact_version }}.pom
path: ./target/${{ env.artifact_name }}-${{ env.artifact_version }}.${{ env.artifact_packaging }}
- name: Workflow Release Notes
uses: peter-evans/repository-dispatch@v2
if: ${{ github.event.inputs.releaseVersion }} != "" && ${{ github.event.inputs.developmentVersion }} != ""
with:
event-type: release-notes
client-payload: '{"auto_release": "true", "artifact": "${{ env.artifact_name }}-${{ env.artifact_version }}"}'
event-type: github-release
client-payload: '{"auto_release": "${{ env.auto_release }}", "artifact": "${{ env.artifact_name }}-${{ env.artifact_version }}"}'
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
<!-- For pre 2021 legacy projects you may use https://oss.sonatype.org -->
<!-- See https://central.sonatype.org/publish/release/#login-into-ossrh for details -->
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<autoReleaseAfterClose>${env.AUTO_RELEASE_AFTER_CLOSE}</autoReleaseAfterClose>
</configuration>
</plugin>
<!-- https://blog.sonatype.com/2010/01/how-to-generate-pgp-signatures-with-maven/-->
Expand Down

0 comments on commit 7aa309d

Please sign in to comment.