Answer a question

I am trying to make auto- or semi-auto versioning into GitHub.

I looked into the automation release workflow possibilities and it doesn't seem like anything standard for GitHub.

I want to have an automatic update of version in pom.xml whenever I create a tag on GitHub or whenever I merge into the master branch.

Answers

I found a workaround solution with Github Actions that can be extended further. Whenever I release and I manually specify release notes and changelog, so this release version can be taken from github.event.release.tag_name

mvn -B versions:set -DnewVersion=${{ github.event.release.tag_name }} -DgenerateBackupPoms=false

The reference to the actual GitHub workflow is here.

.github/workflows/deploy.yml at the time of writing:

name: Publish package to the Maven Central Repository
on:
  release:
    types: [created]

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Check out Git repository
        uses: actions/checkout@v2
      - name: Install Java and Maven
        uses: actions/setup-java@v1
        with:
          java-version: 8
      - if: github.event.release
        name: Update version in pom.xml (Release only)
        run: mvn -B versions:set -DnewVersion=${{ github.event.release.tag_name }} -DgenerateBackupPoms=false
      - name: Release Maven package
        uses: samuelmeuli/action-maven-publish@v1.4.0
        with:
          maven_profiles: deploy, verify
          gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
          gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
          nexus_username: ${{ secrets.OSSRH_USERNAME }}
          nexus_password: ${{ secrets.OSSRH_TOKEN }}
Logo

ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!

更多推荐