Skip to content

Commit

Permalink
ci: automatic java binding release (#2557)
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun authored Jun 28, 2023
1 parent 050c044 commit 960a8de
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 23 deletions.
36 changes: 14 additions & 22 deletions .github/workflows/bindings_java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ jobs:
working-directory: bindings/java
run: mvn clean verify

stage-snapshot:
stage-releases:
runs-on: ${{ matrix.os }}
if: github.event_name == 'push' || !github.event.pull_request.head.repo.fork
if: ${{ startsWith(github.ref, 'refs/tags/') }}
strategy:
matrix:
include:
Expand Down Expand Up @@ -107,13 +107,18 @@ jobs:
distribution: 'temurin'
java-version: '8'
cache: 'maven'
server-id: apache.releases.https
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: ${{ env.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Local staging
working-directory: bindings/java
run: mvn -Papache-release package verify org.sonatype.plugins:nexus-staging-maven-plugin:deploy -Dsuffix.snapshot="-SNAPSHOT" -Djni.classifier=${{ matrix.classifier }} -DskipTests=true -DaltStagingDirectory=local-staging -DskipRemoteStaging=true
run: mvn -Papache-release package verify org.sonatype.plugins:nexus-staging-maven-plugin:deploy -Djni.classifier=${{ matrix.classifier }} -DskipTests=true -DaltStagingDirectory=local-staging -DskipRemoteStaging=true -DserverId=apache.releases.https -DnexusUrl=https://repository.apache.org
env:
MAVEN_USERNAME: ${{ secrets.NEXUS_USER }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.NEXUS_PW }}
MAVEN_GPG_PASSPHRASE: ${{ env.MAVEN_GPG_PASSPHRASE }}

- name: Upload local staging directory
Expand All @@ -123,10 +128,10 @@ jobs:
path: bindings/java/local-staging
if-no-files-found: error

deploy-snapshots:
deploy-releases:
runs-on: ubuntu-latest
if: github.event_name == 'push' || !github.event.pull_request.head.repo.fork
needs: [stage-snapshot]
if: ${{ startsWith(github.ref, 'refs/tags/') }}
needs: [stage-releases]
steps:
- uses: actions/checkout@v3
- name: Load secret
Expand All @@ -145,7 +150,7 @@ jobs:
distribution: 'temurin'
java-version: '8'
cache: 'maven'
server-id: apache.snapshots.https
server-id: apache.releases.https
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: ${{ env.MAVEN_GPG_PRIVATE_KEY }}
Expand Down Expand Up @@ -177,25 +182,12 @@ jobs:
path: ~/osx-aarch_64-local-staging

- name: Merge staging repositories
run: |
mkdir -p ~/local-staging/deferred
# cat ~/windows-x86_64-local-staging/deferred/.index >> ~/local-staging/deferred/.index
# cp -r ~/windows-x86_64-local-staging/deferred/* ~/local-staging/deferred/
cat ~/linux-x86_64-local-staging/deferred/.index >> ~/local-staging/deferred/.index
cp -r ~/linux-x86_64-local-staging/deferred/* ~/local-staging/deferred/
cat ~/osx-x86_64-local-staging/deferred/.index >> ~/local-staging/deferred/.index
cp -r ~/osx-x86_64-local-staging/deferred/* ~/local-staging/deferred/
cat ~/osx-aarch_64-local-staging/deferred/.index >> ~/local-staging/deferred/.index
cp -r ~/osx-aarch_64-local-staging/deferred/* ~/local-staging/deferred/
run: bash ./scripts/merge_local_staging.sh $LOCAL_STAGING_DIR/staging ~/linux-x86_64-local-staging/staging ~/osx-x86_64-local-staging/staging ~/osx-aarch_64-local-staging/staging # ~/windows-x86_64-local-staging/staging

- name: Deploy local staged artifacts
if: ${{ github.event_name != 'pull_request' }}
working-directory: bindings/java
run: mvn org.sonatype.plugins:nexus-staging-maven-plugin:deploy-staged -Dsuffix.snapshot="-SNAPSHOT" -DaltStagingDirectory=$LOCAL_STAGING_DIR
run: mvn org.sonatype.plugins:nexus-staging-maven-plugin:deploy-staged -DaltStagingDirectory=$LOCAL_STAGING_DIR -DskipStagingRepositoryClose=true -DserverId=apache.releases.https -DnexusUrl=https://repository.apache.org
env:
MAVEN_USERNAME: ${{ secrets.NEXUS_USER }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.NEXUS_PW }}
Expand Down
2 changes: 1 addition & 1 deletion bindings/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<groupId>org.apache.opendal</groupId>
<artifactId>opendal-java</artifactId>
<version>0.38.0${suffix.snapshot}</version>
<version>0.38.0</version>

<url>https://opendal.apache.org</url>
<mailingLists>
Expand Down
38 changes: 38 additions & 0 deletions scripts/merge_local_staging.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

set -e
if [ "$#" -lt 2 ]; then
echo "Expected target directory and at least one local staging directory"
exit 1
fi
TARGET=$1

for ((i=2; i<=$#; i++))
do
DIR="${!i}"
SUB_DIR=$(ls -d "${DIR}"/* | awk -F / '{print $NF}')

if [ ! -d "${TARGET}/${SUB_DIR}" ]
then
mkdir -p "${TARGET}/${SUB_DIR}"
fi
cat "${DIR}"/"${SUB_DIR}"/.index >> "${TARGET}/${SUB_DIR}"/.index
cp -r "${DIR}"/"${SUB_DIR}"/* "${TARGET}/${SUB_DIR}"/
done

0 comments on commit 960a8de

Please sign in to comment.