Skip to content

Commit

Permalink
Publish to maven central from github actions on MacOS and Linux.
Browse files Browse the repository at this point in the history
Signed-off-by: Tao He <sighingnow@gmail.com>
  • Loading branch information
sighingnow committed Aug 31, 2022
1 parent 5a479c5 commit af10f97
Show file tree
Hide file tree
Showing 19 changed files with 739 additions and 70 deletions.
86 changes: 54 additions & 32 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,23 @@

name: CI on Linux

on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]

concurrency:
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true

env:
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache

MAVEN_ARGS: "--no-transfer-progress"
LLVM11_HOME: /opt/llvm11.0.0

jobs:
fastffi-ci:
runs-on: ubuntu-20.04
container: vineyardcloudnative/manylinux2010-llvm11:latest
container: vineyardcloudnative/manylinux-llvm:2014-11.0.0
steps:
- uses: actions/checkout@v1

Expand All @@ -32,32 +39,31 @@ jobs:
curl -L https://git.io/vaHfR --output /usr/local/bin/screenfetch
chmod +x /usr/local/bin/screenfetch
- name: Setup Java
env:
LLVM11_HOME: /opt/llvm11.0.0
JAVA_HOME: /usr/lib/jvm/java-8-zulu-amd64
run: |
curl -L -O https://cdn.azul.com/zulu/bin/zulu8.64.0.19-ca-jdk8.0.345-linux_x64.tar.gz
tar zxf zulu8.64.0.19-ca-jdk8.0.345-linux_x64.tar.gz
mkdir -p $(dirname $JAVA_HOME)
mv zulu8.64.0.19-ca-jdk8.0.345-linux_x64 $JAVA_HOME
yum install -y ccache
- name: Setup Maven
env:
LLVM11_HOME: /opt/llvm11.0.0
JAVA_HOME: /usr/lib/jvm/java-8-zulu-amd64
MAVEN_HOME: /usr/lib/jvm/maven
- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '8'
cache: 'maven'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.OSSRH_MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Set up Maven
uses: stCarolas/setup-maven@master
with:
maven-version: 3.8.4

- name: Validate settings
run: |
curl -L -O https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
tar zxf apache-maven-3.8.6-bin.tar.gz
mkdir -p $(dirname $MAVEN_HOME)
mv apache-maven-3.8.6 $MAVEN_HOME
mkdir -p /root/.m2
cp /github/home/.m2/settings.xml /root/.m2/settings.xml || true
cat /root/.m2/settings.xml
- name: Check environment
env:
LLVM11_HOME: /opt/llvm11.0.0
JAVA_HOME: /usr/lib/jvm/java-8-zulu-amd64
MAVEN_HOME: /usr/lib/jvm/maven
run: |
export PATH=$PATH:$LLVM11_HOME/bin:$JAVA_HOME/bin:$MAVEN_HOME/bin
Expand Down Expand Up @@ -86,21 +92,37 @@ jobs:
mvn --version
- name: Build, test and install
env:
LLVM11_HOME: /opt/llvm11.0.0
JAVA_HOME: /usr/lib/jvm/java-8-zulu-amd64
MAVEN_HOME: /usr/lib/jvm/maven
MAVEN_ARGS: "--no-transfer-progress"
run: |
export PATH=$PATH:$LLVM11_HOME/bin:$JAVA_HOME/bin:$MAVEN_HOME/bin
./build.sh
- name: Publish package
if: ${{ github.event_name == 'workflow_dispatch' && github.repository == 'alibaba/fastFFI' }}
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_MAVEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_MAVEN_GPG_PASSPHRASE }}
run: |
export PATH=$PATH:$LLVM11_HOME/bin:$JAVA_HOME/bin:$MAVEN_HOME/bin
# staging profile id: obtained from "mvn nexus-staging:rc-list-profiles"
# staging repository id: obtained from "mvn nexus-staging:rc-open"
mvn --batch-mode deploy \
-Prelease \
-Dmaven.deploy.skip=true \
-Dstaging.repository=${{ secrets.OSSRH_MAVEN_STAGING_REPOSITORY_ID }} \
-DstagingProfileId=${{ secrets.OSSRH_MAVEN_STAGING_PROFILE_ID }} \
-DstagingRepositoryId=${{ secrets.OSSRH_MAVEN_STAGING_REPOSITORY_ID }} \
-Dgpg.passphrase=${{ secrets.OSSRH_MAVEN_GPG_PASSPHRASE }} \
-DskipTests
- name: Packaging artifacts inside the container
run: |
tar zcvf fastffi-jars-x86-64-manylinux2010.tar.gz /root/.m2/repository/com/alibaba/fastffi
tar zcvf fastffi-jars-x86-64-manylinux2014.tar.gz /root/.m2/repository/com/alibaba/fastffi
- uses: actions/upload-artifact@v1
with:
name: fastffi-jars-x86-64-manylinux2010
path: fastffi-jars-x86-64-manylinux2010.tar.gz
name: fastffi-jars-x86-64-manylinux2014
path: fastffi-jars-x86-64-manylinux2014.tar.gz
42 changes: 38 additions & 4 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ concurrency:
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true

env:
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache

MAVEN_ARGS: "--no-transfer-progress"

jobs:
fastffi-ci:
runs-on: macos-11
Expand All @@ -28,19 +34,28 @@ jobs:

- name: Install dependencies
run: |
brew install llvm@11 screenfetch python3 cmake
brew install llvm@11 screenfetch python3 cmake ccache
- uses: actions/setup-java@v2
- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '8'
cache: 'maven'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.OSSRH_MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Set up Maven
uses: stCarolas/setup-maven@master
with:
maven-version: 3.8.4

- name: Validate settings
run: |
cat $HOME/.m2/settings.xml
- name: Check environment
run: |
export LLVM11_HOME=$(brew --prefix llvm@11)
Expand Down Expand Up @@ -70,14 +85,33 @@ jobs:
mvn --version
- name: Build, test and install
env:
MAVEN_ARGS: "--no-transfer-progress"
run: |
export LLVM11_HOME=$(brew --prefix llvm@11)
# clean & install
./build.sh
- name: Publish package
if: ${{ github.event_name == 'workflow_dispatch' && github.repository == 'alibaba/fastFFI' }}
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_MAVEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_MAVEN_GPG_PASSPHRASE }}
run: |
export LLVM11_HOME=$(brew --prefix llvm@11)
# staging profile id: obtained from "mvn nexus-staging:rc-list-profiles"
# staging repository id: obtained from "mvn nexus-staging:rc-open"
mvn --batch-mode deploy \
-Prelease \
-Dmaven.deploy.skip=true \
-Dstaging.repository=${{ secrets.OSSRH_MAVEN_STAGING_REPOSITORY_ID }} \
-DstagingProfileId=${{ secrets.OSSRH_MAVEN_STAGING_PROFILE_ID }} \
-DstagingRepositoryId=${{ secrets.OSSRH_MAVEN_STAGING_REPOSITORY_ID }} \
-Dgpg.passphrase=${{ secrets.OSSRH_MAVEN_GPG_PASSPHRASE }} \
-DskipTests
- uses: actions/upload-artifact@v3
with:
name: fastffi-jars-x86-64-macos-11
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,28 @@ Basically, the build procedure the following binary:
3. Use fastFFI with Maven.

```xml
<properties>
<fastffi.revision>0.1.1</fastffi.revision>
</properties>

<dependencies>
<!-- The FFI annotation -->
<dependency>
<groupId>com.alibaba.fastffi</groupId>
<artifactId>ffi</artifactId>
<version>0.1</version>
<version>${fastffi.revision}</version>
</dependency>
<!-- The FFI annotation processor for code generation -->
<dependency>
<groupId>com.alibaba.fastffi</groupId>
<artifactId>annotation-processor</artifactId>
<version>0.1</version>
<version>${revision}</version>
</dependency>
<!-- The runtime component of LLVM4JNI -->
<dependency>
<groupId>com.alibaba.fastffi</groupId>
<artifactId>llvm4jni-runtime</artifactId>
<version>0.1</version>
<version>${revision}</version>
</dependency>
</dependencies>
```
Expand Down
44 changes: 43 additions & 1 deletion annotation-processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba.fastffi</groupId>
<artifactId>fastffi-parent</artifactId>
<version>0.1</version>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -59,6 +59,48 @@
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>release</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
44 changes: 43 additions & 1 deletion binding-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.alibaba.fastffi</groupId>
<artifactId>fastffi-parent</artifactId>
<version>0.1</version>
<version>${revision}</version>
</parent>

<artifactId>binding-generator</artifactId>
Expand Down Expand Up @@ -68,6 +68,48 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>release</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit af10f97

Please sign in to comment.