Merge pull request #406 from tausif010/feature/reset-tsMetadta-field #260
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: java-release-main | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- pom.xml | |
- .github/workflows/release.yml | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
environment: CD | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Apache Maven Central | |
uses: actions/setup-java@v3 | |
with: # running setup-java again overwrites the settings.xml | |
distribution: "temurin" | |
java-version: "17" | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_CENTRAL_TOKEN | |
gpg-private-key: ${{ secrets.SONATYPE_OSSRH_GPG_PRIVATE_KEY }} | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
- name: Install jq | |
run: | | |
curl http://stedolan.github.io/jq/download/linux64/jq -o ./jq | |
chmod a+x ./jq | |
- name: Detect version change | |
id: detect | |
run: | | |
CENTRAL_VERSION=$(curl -H "Accept: application/json" -L "https://search.maven.org/solrsearch/select?q=g:com.cognite+a:cdf-sdk-java&rows=1&wt=json" | jq -r .response.docs[0].latestVersion) | |
MVN_VERSION=$(mvn -q \ | |
-Dexec.executable=echo \ | |
-Dexec.args='${project.version}' \ | |
--non-recursive \ | |
exec:exec) | |
echo "CENTRAL_VERSION=$CENTRAL_VERSION" | |
echo "MVN_VERSION=$MVN_VERSION" | |
echo "central_version=$CENTRAL_VERSION" >> $GITHUB_OUTPUT | |
echo "maven_version=$MVN_VERSION" >> $GITHUB_OUTPUT | |
- name: Publish to Apache Maven Central | |
if: ${{ !endsWith(steps.detect.outputs.maven_version, 'SNAPSHOT') && steps.detect.outputs.maven_version != steps.detect.outputs.central_version }} | |
run: | | |
mvn -B clean deploy -Prelease | |
env: | |
MAVEN_USERNAME: ${{ secrets.SONATYPE_OSSRH_USER }} | |
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_OSSRH_PASSWORD }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.SONATYPE_OSSRH_GPG_KEY_PASSPHRASE }} | |