Skip to content

Merge pull request #111 from levigo/dependabot/maven/com.neverpile-ur… #96

Merge pull request #111 from levigo/dependabot/maven/com.neverpile-ur…

Merge pull request #111 from levigo/dependabot/maven/com.neverpile-ur… #96

name: Continuous Delivery
on:
push:
branches:
- master
paths-ignore:
- '.github/**'
- '**/README.md'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Bump version and create tag
id: semanticversion
uses: mathieudutour/[email protected]
with:
release_branches: master
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Verify and print new build number
run: |
if echo '${{ steps.semanticversion.outputs.new_tag }}' |grep -Eq '^v[0-9]+[.][0-9]+[.][0-9]+$'; then
echo Tag '${{ steps.semanticversion.outputs.new_tag }}', New version '${{ steps.semanticversion.outputs.new_version }}', Changelog '${{ steps.semanticversion.outputs.changelog }}'
else
echo 'unexpected tag format - aborting'
exit -1
fi
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
## Build with maven
- name: Prepare maven settings
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p ~/.m2
echo "<settings><servers><server><id>github</id><username>x-access-token</username><password>${GITHUB_TOKEN}</password></server></servers></settings>" > ~/.m2/settings.xml
- name: Set version
id: version
run: |
echo Releasing as ${{ steps.semanticversion.outputs.new_version }}
mvn versions:set -DnewVersion=${{ steps.semanticversion.outputs.new_version }}
- name: Perform build
run: mvn -B package --file pom.xml
## Deploy
- name: Deploy package
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY_URL: ${{ secrets.REPOSITORY_URL }}
REPOSITORY_USERID: ${{ secrets.REPOSITORY_USERID }}
REPOSITORY_CREDENTIALS: ${{ secrets.REPOSITORY_CREDENTIALS }}
run: |
mkdir -p ~/.m2
echo "<settings><servers><server><id>neverpile</id><username>${REPOSITORY_USERID}</username><password>${REPOSITORY_CREDENTIALS}</password></server></servers></settings>" > ~/.m2/settings.xml
mvn deploy -Dmaven.test.skip.exec=true -DaltDeploymentRepository=neverpile::default::${REPOSITORY_URL}
## Update README.md
- name: Edit README.md to contain version number
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git checkout master
git reset --hard HEAD
sed -ri "s,<version>.*</version>,<version>${{ steps.semanticversion.outputs.new_version }}</version>," README.md
sed -ri "s,version-[0-9a-z.]+-,version-${{ steps.semanticversion.outputs.new_version }}-," README.md
sed -ri "s,neverpile-fusion/tree/[0-9a-z.]+,neverpile-fusion/tree/${{ steps.semanticversion.outputs.new_tag }}," README.md
git add README.md
git commit -m "Edit README.md to contain correct version"
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: master
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Notify Mattermost
uses: 8398a7/action-slack@v3
if: failure()
with:
username: GitHub
icon_emoji: octocat
channel: "neverpile-ci"
status: ${{ job.status }}
fields: repo,message,commit,author
text: Released new version `${{ steps.semanticversion.outputs.new_version }}` of *${{ github.repository }}* failed!
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}