From 47efe37a0ef586e410f335f0e7ce6394121e688e Mon Sep 17 00:00:00 2001 From: songyinyin Date: Mon, 18 Dec 2023 12:00:06 +0800 Subject: [PATCH] =?UTF-8?q?Github=20Action:=20=E6=9E=84=E5=BB=BA=E7=89=A9?= =?UTF-8?q?=E7=9A=84=E7=89=88=E6=9C=AC=E5=8F=B7=E4=BD=BF=E7=94=A8=20pom=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=AD=E5=AE=9A=E4=B9=89=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/linux_mac_native.yml | 27 ++++++++++++++++---------- .github/workflows/windows-native.yml | 15 ++++++++++---- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/.github/workflows/linux_mac_native.yml b/.github/workflows/linux_mac_native.yml index 504fbfc5..4dd77101 100644 --- a/.github/workflows/linux_mac_native.yml +++ b/.github/workflows/linux_mac_native.yml @@ -45,34 +45,41 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- + - name: Set vars + shell: bash + run: | + OS=$(echo '${{ runner.os }}' | awk '{print tolower($0)}') + [[ $OS == 'ubuntu' ]] && echo "OS=linux" >> $GITHUB_ENV || echo "OS=$OS" >> $GITHUB_ENV + [[ $OS == 'macos' ]] && echo "OS=darwin" >> $GITHUB_ENV || echo "OS=$OS" >> $GITHUB_ENV + echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV - name: Build with Maven (neutrino-proxy-server) run: | mvn clean install -pl neutrino-proxy-core -am -DskipTests --no-transfer-progress cd neutrino-proxy-server mvn clean native:compile -P native --file pom.xml --no-transfer-progress chmod +x target/neutrino-proxy-server - cp target/neutrino-proxy-server ./../neutrino-proxy-server-${{ github.ref_name }} - cp target/classes/app-copy.yml ./../neutrino-proxy-server-${{ github.ref_name }}/app.yml + cp target/neutrino-proxy-server ./../neutrino-proxy-server-${{ env.VERSION }} + cp target/classes/app-copy.yml ./../neutrino-proxy-server-${{ env.VERSION }}/app.yml - name: Archive zip (neutrino-proxy-server) uses: thedoctor0/zip-release@master with: type: 'zip' - path: 'neutrino-proxy-server-${{ github.ref_name }}' - filename: neutrino-proxy-server-${{ matrix.os }}-${{ github.ref_name }}.zip + path: 'neutrino-proxy-server-${{ env.VERSION }}' + filename: neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}.zip - name: Build with Maven (neutrino-proxy-client) run: | cd neutrino-proxy-client mvn clean package --file pom.xml --no-transfer-progress mvn clean native:compile -P native --file pom.xml --no-transfer-progress chmod +x target/neutrino-proxy-client - cp target/neutrino-proxy-client ./../neutrino-proxy-client-${{ github.ref_name }} - cp target/classes/app-copy.yml ./../neutrino-proxy-client-${{ github.ref_name }}/app.yml + cp target/neutrino-proxy-client ./../neutrino-proxy-client-${{ env.VERSION }} + cp target/classes/app-copy.yml ./../neutrino-proxy-client-${{ env.VERSION }}/app.yml - name: Archive zip (neutrino-proxy-client) uses: thedoctor0/zip-release@master with: type: 'zip' - path: 'neutrino-proxy-client-${{ github.ref_name }}' - filename: neutrino-proxy-client-${{ matrix.os }}-${{ github.ref_name }}.zip + path: 'neutrino-proxy-client-${{ env.VERSION }}' + filename: neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}.zip # GitHub 上创建 release - name: Release uses: softprops/action-gh-release@v1 @@ -81,7 +88,7 @@ jobs: files: | neutrino-proxy-server/target/neutrino-proxy-server.jar neutrino-proxy-client/target/neutrino-proxy-client.jar - neutrino-proxy-server-${{ matrix.os }}-${{ github.ref_name }}.zip - neutrino-proxy-client-${{ matrix.os }}-${{ github.ref_name }}.zip + neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}.zip + neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}.zip prerelease: true token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/windows-native.yml b/.github/workflows/windows-native.yml index ebebef7f..4f445268 100644 --- a/.github/workflows/windows-native.yml +++ b/.github/workflows/windows-native.yml @@ -44,6 +44,13 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- + - name: Set vars + shell: bash + run: | + OS=$(echo '${{ runner.os }}' | awk '{print tolower($0)}') + [[ $OS == 'ubuntu' ]] && echo "OS=linux" >> $GITHUB_ENV || echo "OS=$OS" >> $GITHUB_ENV + [[ $OS == 'macos' ]] && echo "OS=darwin" >> $GITHUB_ENV || echo "OS=$OS" >> $GITHUB_ENV + echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV - name: Build with Maven (neutrino-proxy-server) run: | set MAVEN_OPTS="-Duser.language=UTF-8 -Dfile.encoding=UTF-8" @@ -56,7 +63,7 @@ jobs: with: type: 'zip' path: 'neutrino-proxy-server.exe' - filename: neutrino-proxy-server-${{ matrix.os }}-${{ github.ref_name }}.zip + filename: neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}.zip - name: Build with Maven (neutrino-proxy-client) run: | set MAVEN_OPTS="-Duser.language=UTF-8 -Dfile.encoding=UTF-8" @@ -69,7 +76,7 @@ jobs: with: type: 'zip' path: 'neutrino-proxy-client.exe' - filename: neutrino-proxy-client-${{ matrix.os }}-${{ github.ref_name }}.zip + filename: neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}.zip # GitHub 上创建 release - name: Release uses: softprops/action-gh-release@v1 @@ -78,7 +85,7 @@ jobs: files: | neutrino-proxy-server/target/neutrino-proxy-server.jar neutrino-proxy-client/target/neutrino-proxy-client.jar - neutrino-proxy-server-${{ matrix.os }}-${{ github.ref_name }}.zip - neutrino-proxy-client-${{ matrix.os }}-${{ github.ref_name }}.zip + neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}.zip + neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}.zip prerelease: true token: ${{ secrets.GITHUB_TOKEN }}