Skip to content

Merge pull request #308 from xdev-software/develop #12

Merge pull request #308 from xdev-software/develop

Merge pull request #308 from xdev-software/develop #12

Workflow file for this run

name: Release
on:
push:
branches: [ master ]
env:
PRIMARY_MAVEN_MODULE: ${{ github.event.repository.name }}
DEMO_MAVEN_MODULE: ${{ github.event.repository.name }}-demo
permissions:
contents: write
pull-requests: write
jobs:
check_code: # Validates the code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Build with Maven
run: mvn -B clean package -Pproduction
- name: Check for uncommited changes
run: |
if [[ "$(git status --porcelain)" != "" ]]; then
echo ----------------------------------------
echo git status
echo ----------------------------------------
git status
echo ----------------------------------------
echo git diff
echo ----------------------------------------
git diff
echo ----------------------------------------
echo Troubleshooting
echo ----------------------------------------
echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && mvn -B clean package -Pproduction"
exit 1
fi
prepare_release:
runs-on: ubuntu-latest
needs: [check_code]
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
- name: Configure Git
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
- name: Un-SNAP root
run: mvn -B versions:set -DremoveSnapshot -DgenerateBackupPoms=false
- name: Un-SNAP demo
run: mvn -B versions:set -DremoveSnapshot -DgenerateBackupPoms=false
working-directory: ${{ env.DEMO_MAVEN_MODULE }}
- name: Un-SNAP
run: mvn -B versions:set -DremoveSnapshot -DgenerateBackupPoms=false
working-directory: ${{ env.PRIMARY_MAVEN_MODULE }}
- name: Get version
id: version
run: |
version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "release=$version" >> $GITHUB_OUTPUT
echo "releasenumber=${version//[!0-9]/}" >> $GITHUB_OUTPUT
working-directory: ${{ env.PRIMARY_MAVEN_MODULE }}
- name: Commit and Push
run: |
git add -A
git commit -m "Release ${{ steps.version.outputs.release }}"
git push origin
git tag v${{ steps.version.outputs.release }}
git push origin --tags
- name: Create Release
id: create_release
uses: shogo82148/actions-create-release@v1
with:
tag_name: v${{ steps.version.outputs.release }}
release_name: v${{ steps.version.outputs.release }}
commitish: master
body: |
## [Changelog](https://github.com/xdev-software/${{ env.PRIMARY_MAVEN_MODULE }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }})
See [Changelog#v${{ steps.version.outputs.release }}](https://github.com/xdev-software/${{ env.PRIMARY_MAVEN_MODULE }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }}) for more information.
## Installation
Add the following lines to your pom:
```XML
<dependency>
<groupId>com.xdev-software</groupId>
<artifactId>${{ env.PRIMARY_MAVEN_MODULE }}</artifactId>
<version>${{ steps.version.outputs.release }}</version>
</dependency>
### Additional notes
* [Spring-Boot] You may have to include ``software/xdev`` inside [``vaadin.whitelisted-packages``](https://vaadin.com/docs/latest/integrations/spring/configuration#configure-the-scanning-of-packages)
```
publish_central: # Publish the code to central
runs-on: ubuntu-latest
needs: [prepare_release]
steps:
- uses: actions/checkout@v4
- name: Init Git and pull
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git pull
- name: Set up JDK Apache Maven Central
uses: actions/setup-java@v4
with: # running setup-java again overwrites the settings.xml
java-version: '17'
distribution: 'temurin'
server-id: ossrh
server-username: MAVEN_CENTRAL_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-passphrase: MAVEN_GPG_PASSPHRASE
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
- name: Publish to Apache Maven Central
run: mvn -B deploy -Possrh
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
working-directory: ${{ env.PRIMARY_MAVEN_MODULE }}
publish-pages:
name: Publish dependencies and licenses to github pages
runs-on: ubuntu-latest
needs: [prepare_release]
steps:
- uses: actions/checkout@v4
- name: Init Git and pull
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git pull
- name: Setup - Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Build dependencies/licenses files
run: mvn -B project-info-reports:dependencies
working-directory: ${{ env.PRIMARY_MAVEN_MODULE }}
- name: Upload licenses - Upload Artifact
uses: actions/upload-artifact@v3
with:
name: dependencies-licenses
path: ${{ env.PRIMARY_MAVEN_MODULE }}/target/site
- name: Generate docs/dependencies dir
run: mkdir -p docs/dependencies
- name: Move built files into docs/dependencies
run: mv ${{ env.PRIMARY_MAVEN_MODULE }}/target/site/* docs/dependencies
- name: Rename dependencies.html to index.html
working-directory: docs/dependencies
run: mv dependencies.html index.html
- name: Copy Readme into docs (as index.md)
run: cp README.md docs/index.md
- name: Configure Pages
working-directory: docs
run: |-
echo "theme: jekyll-theme-tactile" > _config.yml
- name: Deploy to Github pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
enable_jekyll: true
after_release:
runs-on: ubuntu-latest
needs: [publish_central]
steps:
- uses: actions/checkout@v4
- name: Init Git and pull
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git pull
- name: Inc Version and SNAP root
run: mvn -B build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} -DgenerateBackupPoms=false -DnextSnapshot=true
- name: Inc Version and SNAP demo
run: mvn -B build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} -DgenerateBackupPoms=false -DnextSnapshot=true
working-directory: ${{ env.DEMO_MAVEN_MODULE }}
- name: Inc Version and SNAP
run: mvn -B build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} -DgenerateBackupPoms=false -DnextSnapshot=true
working-directory: ${{ env.PRIMARY_MAVEN_MODULE }}
- name: Git Commit and Push
run: |
git add -A
git commit -m "Preparing for next development iteration"
git push origin
- name: pull-request
env:
GH_TOKEN: ${{ github.token }}
run: |
gh_pr_up() {
gh pr create "$@" || gh pr edit "$@"
}
gh_pr_up -B "develop" \
--title "Sync back" \
--body "An automated PR to sync changes back"