Skip to content

Commit ad6401c

Browse files
authored
ci: fix opendal-java snapshot releases (#2532)
* ci: fix opendal-java snapshot releases Signed-off-by: tison <[email protected]> * ci: decouple version string with release type Signed-off-by: tison <[email protected]> * ci: better trigger Signed-off-by: tison <[email protected]> --------- Signed-off-by: tison <[email protected]>
1 parent b78a82e commit ad6401c

File tree

4 files changed

+137
-130
lines changed

4 files changed

+137
-130
lines changed

.github/workflows/bindings_java.yml

Lines changed: 130 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -70,126 +70,133 @@ jobs:
7070
working-directory: bindings/java
7171
run: mvn clean verify
7272

73-
# stage-snapshot:
74-
# runs-on: ${{ matrix.os }}
75-
# if: github.event_name == 'push' || !github.event.pull_request.head.repo.fork
76-
# strategy:
77-
# matrix:
78-
# include:
79-
# - os: ubuntu-latest
80-
# classifier: linux-x86_64
81-
# - os: windows-latest
82-
# classifier: windows-x86_64
83-
# - os: macos-latest
84-
# classifier: osx-x86_64
85-
# - os: macos-latest
86-
# classifier: osx-aarch_64
87-
# steps:
88-
# - uses: actions/checkout@v3
89-
90-
# - name: Load secret
91-
# id: op-load-secret
92-
# uses: 1password/load-secrets-action@v1
93-
# with:
94-
# export-env: true
95-
# env:
96-
# OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
97-
# MAVEN_GPG_PRIVATE_KEY: op://services/maven/gpg_private_key
98-
# MAVEN_GPG_PASSPHRASE: op://services/maven/gpg_passphrase
99-
100-
# - name: Set up JDK 8
101-
# uses: actions/setup-java@v3
102-
# with:
103-
# distribution: 'temurin'
104-
# java-version: '8'
105-
# cache: 'maven'
106-
# gpg-private-key: ${{ env.MAVEN_GPG_PRIVATE_KEY }}
107-
# gpg-passphrase: ${{ env.MAVEN_GPG_PASSPHRASE }}
108-
# - uses: actions/setup-python@v4
109-
# with:
110-
# python-version: '3.10'
111-
112-
# - name: Local staging
113-
# working-directory: bindings/java
114-
# run: mvn -Papache-release package verify org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DjniClassifier=${{ matrix.classifier }} -DskipTests=true -DaltStagingDirectory=local-staging -DskipRemoteStaging=true
115-
# env:
116-
# MAVEN_GPG_PASSPHRASE: ${{ env.MAVEN_GPG_PASSPHRASE }}
117-
# - name: Upload local staging directory
118-
# uses: actions/upload-artifact@v3
119-
# with:
120-
# name: ${{ matrix.classifier }}-local-staging
121-
# path: bindings/java/local-staging
122-
# if-no-files-found: error
123-
124-
# deploy-snapshots:
125-
# runs-on: ubuntu-latest
126-
# if: github.event_name == 'push' || !github.event.pull_request.head.repo.fork
127-
# needs: [stage-snapshot]
128-
# steps:
129-
# - uses: actions/checkout@v3
130-
# - name: Load secret
131-
# id: op-load-secret
132-
# uses: 1password/load-secrets-action@v1
133-
# with:
134-
# export-env: true
135-
# env:
136-
# OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
137-
# MAVEN_GPG_PRIVATE_KEY: op://services/maven/gpg_private_key
138-
# MAVEN_GPG_PASSPHRASE: op://services/maven/gpg_passphrase
139-
140-
# - name: Set up JDK 8
141-
# uses: actions/setup-java@v3
142-
# with:
143-
# distribution: 'temurin'
144-
# java-version: '8'
145-
# cache: 'maven'
146-
# server-id: apache.snapshots.https
147-
# server-username: MAVEN_USERNAME
148-
# server-password: MAVEN_CENTRAL_TOKEN
149-
# gpg-private-key: ${{ env.MAVEN_GPG_PRIVATE_KEY }}
150-
# gpg-passphrase: ${{ env.MAVEN_GPG_PASSPHRASE }}
151-
152-
# - name: Prepare enviroment variables
153-
# run: echo "LOCAL_STAGING_DIR=$HOME/local-staging" >> $GITHUB_ENV
154-
155-
# - name: Download windows staging directory
156-
# uses: actions/download-artifact@v3
157-
# with:
158-
# name: windows-x86_64-local-staging
159-
# path: ~/windows-x86_64-local-staging
160-
# - name: Download linux staging directory
161-
# uses: actions/download-artifact@v3
162-
# with:
163-
# name: linux-x86_64-local-staging
164-
# path: ~/linux-x86_64-local-staging
165-
# - name: Download darwin staging directory
166-
# uses: actions/download-artifact@v3
167-
# with:
168-
# name: osx-x86_64-local-staging
169-
# path: ~/osx-x86_64-local-staging
170-
# - name: Download darwin (aarch64) staging directory
171-
# uses: actions/download-artifact@v3
172-
# with:
173-
# name: osx-aarch_64-local-staging
174-
# path: ~/osx-aarch_64-local-staging
175-
176-
# - name: Merge staging repositories
177-
# run: |
178-
# mkdir -p ~/local-staging/deferred
179-
# cat ~/windows-x86_64-local-staging/deferred/.index >> ~/local-staging/deferred/.index
180-
# cp -r ~/windows-x86_64-local-staging/deferred/* ~/local-staging/deferred/
181-
# cat ~/linux-x86_64-local-staging/deferred/.index >> ~/local-staging/deferred/.index
182-
# cp -r ~/linux-x86_64-local-staging/deferred/* ~/local-staging/deferred/
183-
# cat ~/osx-x86_64-local-staging/deferred/.index >> ~/local-staging/deferred/.index
184-
# cp -r ~/osx-x86_64-local-staging/deferred/* ~/local-staging/deferred/
185-
# cat ~/osx-aarch_64-local-staging/deferred/.index >> ~/local-staging/deferred/.index
186-
# cp -r ~/osx-aarch_64-local-staging/deferred/* ~/local-staging/deferred/
187-
188-
# - name: Deploy local staged artifacts
189-
# if: ${{ github.event_name != 'pull_request' }}
190-
# working-directory: bindings/java
191-
# run: mvn org.sonatype.plugins:nexus-staging-maven-plugin:deploy-staged -DaltStagingDirectory=$LOCAL_STAGING_DIR
192-
# env:
193-
# MAVEN_USERNAME: ${{ secrets.NEXUS_USER }}
194-
# MAVEN_CENTRAL_TOKEN: ${{ secrets.NEXUS_PW }}
195-
# MAVEN_GPG_PASSPHRASE: ${{ env.MAVEN_GPG_PASSPHRASE }}
73+
stage-snapshot:
74+
runs-on: ${{ matrix.os }}
75+
if: ${{ github.event_name == 'push' || !github.event.pull_request.head.repo.fork }}}
76+
strategy:
77+
matrix:
78+
include:
79+
- os: ubuntu-latest
80+
classifier: linux-x86_64
81+
# FIXME: Windows is not supported due to 1password action limitation.
82+
# - os: windows-latest
83+
# classifier: windows-x86_64
84+
- os: macos-latest
85+
classifier: osx-x86_64
86+
- os: macos-latest
87+
classifier: osx-aarch_64
88+
steps:
89+
- uses: actions/checkout@v3
90+
- uses: actions/setup-python@v4
91+
with:
92+
python-version: '3.10'
93+
94+
- name: Load secret
95+
id: op-load-secret
96+
uses: 1password/load-secrets-action@v1
97+
with:
98+
export-env: true
99+
env:
100+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
101+
MAVEN_GPG_PRIVATE_KEY: op://services/maven/gpg_private_key
102+
MAVEN_GPG_PASSPHRASE: op://services/maven/gpg_passphrase
103+
104+
- name: Set up JDK 8
105+
uses: actions/setup-java@v3
106+
with:
107+
distribution: 'temurin'
108+
java-version: '8'
109+
cache: 'maven'
110+
gpg-private-key: ${{ env.MAVEN_GPG_PRIVATE_KEY }}
111+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
112+
113+
- name: Local staging
114+
working-directory: bindings/java
115+
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
116+
env:
117+
MAVEN_GPG_PASSPHRASE: ${{ env.MAVEN_GPG_PASSPHRASE }}
118+
119+
- name: Upload local staging directory
120+
uses: actions/upload-artifact@v3
121+
with:
122+
name: ${{ matrix.classifier }}-local-staging
123+
path: bindings/java/local-staging
124+
if-no-files-found: error
125+
126+
deploy-snapshots:
127+
runs-on: ubuntu-latest
128+
if: ${{ github.event_name == 'push' || !github.event.pull_request.head.repo.fork }}}
129+
needs: [stage-snapshot]
130+
steps:
131+
- uses: actions/checkout@v3
132+
- name: Load secret
133+
id: op-load-secret
134+
uses: 1password/load-secrets-action@v1
135+
with:
136+
export-env: true
137+
env:
138+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
139+
MAVEN_GPG_PRIVATE_KEY: op://services/maven/gpg_private_key
140+
MAVEN_GPG_PASSPHRASE: op://services/maven/gpg_passphrase
141+
142+
- name: Set up JDK 8
143+
uses: actions/setup-java@v3
144+
with:
145+
distribution: 'temurin'
146+
java-version: '8'
147+
cache: 'maven'
148+
server-id: apache.snapshots.https
149+
server-username: MAVEN_USERNAME
150+
server-password: MAVEN_CENTRAL_TOKEN
151+
gpg-private-key: ${{ env.MAVEN_GPG_PRIVATE_KEY }}
152+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
153+
154+
- name: Prepare enviroment variables
155+
run: echo "LOCAL_STAGING_DIR=$HOME/local-staging" >> $GITHUB_ENV
156+
157+
# - name: Download windows staging directory
158+
# uses: actions/download-artifact@v3
159+
# with:
160+
# name: windows-x86_64-local-staging
161+
# path: ~/windows-x86_64-local-staging
162+
163+
- name: Download linux staging directory
164+
uses: actions/download-artifact@v3
165+
with:
166+
name: linux-x86_64-local-staging
167+
path: ~/linux-x86_64-local-staging
168+
- name: Download darwin staging directory
169+
uses: actions/download-artifact@v3
170+
with:
171+
name: osx-x86_64-local-staging
172+
path: ~/osx-x86_64-local-staging
173+
- name: Download darwin (aarch64) staging directory
174+
uses: actions/download-artifact@v3
175+
with:
176+
name: osx-aarch_64-local-staging
177+
path: ~/osx-aarch_64-local-staging
178+
179+
- name: Merge staging repositories
180+
run: |
181+
mkdir -p ~/local-staging/deferred
182+
183+
# cat ~/windows-x86_64-local-staging/deferred/.index >> ~/local-staging/deferred/.index
184+
# cp -r ~/windows-x86_64-local-staging/deferred/* ~/local-staging/deferred/
185+
186+
cat ~/linux-x86_64-local-staging/deferred/.index >> ~/local-staging/deferred/.index
187+
cp -r ~/linux-x86_64-local-staging/deferred/* ~/local-staging/deferred/
188+
189+
cat ~/osx-x86_64-local-staging/deferred/.index >> ~/local-staging/deferred/.index
190+
cp -r ~/osx-x86_64-local-staging/deferred/* ~/local-staging/deferred/
191+
192+
cat ~/osx-aarch_64-local-staging/deferred/.index >> ~/local-staging/deferred/.index
193+
cp -r ~/osx-aarch_64-local-staging/deferred/* ~/local-staging/deferred/
194+
195+
- name: Deploy local staged artifacts
196+
if: ${{ github.event_name != 'pull_request' }}
197+
working-directory: bindings/java
198+
run: mvn org.sonatype.plugins:nexus-staging-maven-plugin:deploy-staged -Dsuffix.snapshot="-SNAPSHOT" -DaltStagingDirectory=$LOCAL_STAGING_DIR
199+
env:
200+
MAVEN_USERNAME: ${{ secrets.NEXUS_USER }}
201+
MAVEN_CENTRAL_TOKEN: ${{ secrets.NEXUS_PW }}
202+
MAVEN_GPG_PASSPHRASE: ${{ env.MAVEN_GPG_PASSPHRASE }}

bindings/java/pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
<groupId>org.apache.opendal</groupId>
3434
<artifactId>opendal-java</artifactId>
35-
<version>0.37.0</version>
35+
<version>0.37.0${suffix.snapshot}</version>
3636

3737
<url>https://opendal.apache.org</url>
3838
<mailingLists>
@@ -52,8 +52,8 @@
5252
<maven.compiler.source>1.8</maven.compiler.source>
5353
<maven.compiler.target>1.8</maven.compiler.target>
5454

55-
<!-- Use camelCase instead of separating by dots to workaround PowerShell parsing. -->
56-
<jniClassifier>${os.detected.classifier}</jniClassifier>
55+
<jni.classifier>${os.detected.classifier}</jni.classifier>
56+
<suffix.snapshot /> <!-- used by snapshots releases -->
5757

5858
<assertj-version>3.23.1</assertj-version>
5959
<lombok.version>1.18.26</lombok.version>
@@ -166,7 +166,7 @@
166166
<arguments>
167167
<argument>${project.basedir}/tools/build.py</argument>
168168
<argument>--classifier</argument>
169-
<argument>${jniClassifier}</argument>
169+
<argument>${jni.classifier}</argument>
170170
</arguments>
171171
</configuration>
172172
</execution>
@@ -198,7 +198,7 @@
198198
<goal>jar</goal>
199199
</goals>
200200
<configuration>
201-
<classifier>${jniClassifier}</classifier>
201+
<classifier>${jni.classifier}</classifier>
202202
</configuration>
203203
</execution>
204204
</executions>

bindings/java/src/main/java/org/apache/opendal/Environment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public enum Environment {
3939
try (InputStream is = classLoader.getResourceAsStream("bindings.properties")) {
4040
final Properties properties = new Properties();
4141
properties.load(is);
42-
INSTANCE.classifier = properties.getProperty("jniClassifier", UNKNOWN);
42+
INSTANCE.classifier = properties.getProperty("jni.classifier", UNKNOWN);
4343
INSTANCE.projectVersion = properties.getProperty("project.version", UNKNOWN);
4444
} catch (IOException e) {
4545
throw new UncheckedIOException("cannot load environment properties file", e);

bindings/java/src/main/resources/bindings.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
jniClassifier=${jniClassifier}
18+
jni.classifier=${jni.classifier}
1919
project.version=${project.version}

0 commit comments

Comments
 (0)