-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from nixff/pr-gha
[ci] add GHA to release ztm-cli
- Loading branch information
Showing
8 changed files
with
448 additions
and
43 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,291 @@ | ||
name: Release ZTM Cli | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
- 'v*.*.*-*' | ||
- '*.*.*' | ||
- '*.*.*-*' | ||
env: | ||
PACKAGE_OUTPUT: true | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
set-release-version: | ||
name: set-release-version | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set RELEASE_VERSION | ||
id: version | ||
run: | | ||
pwd | ||
ls -l | ||
CI_COMMIT_DATE=$(git log -1 --format="%ad" --date=format:"%Y%m%d%H%M") | ||
echo "CI_COMMIT_DATE=${CI_COMMIT_DATE}" >> $GITHUB_ENV | ||
git fetch --tags | ||
RELEASE_VERSION=`git name-rev --tags --name-only $(git rev-parse HEAD)` | ||
if [ $RELEASE_VERSION = 'undefined' ] | ||
then | ||
echo "release_version=nightly-${CI_COMMIT_DATE}" >> $GITHUB_OUTPUT | ||
echo "version=nightly" >> $GITHUB_OUTPUT | ||
echo "commit_date=${CI_COMMIT_DATE}" >> $GITHUB_OUTPUT | ||
else | ||
echo "release_version=${RELEASE_VERSION}" >> $GITHUB_OUTPUT | ||
echo "commit_date=${CI_COMMIT_DATE}" >> $GITHUB_OUTPUT | ||
fi | ||
CI_COMMIT_SHA=$(git log -1 --format=%H) | ||
echo "commit_sha=$CI_COMMIT_SHA" >> $GITHUB_OUTPUT | ||
- name: Show envs | ||
run: export | ||
outputs: | ||
release_version: ${{steps.version.outputs.release_version}} | ||
commit_date: ${{steps.version.outputs.commit_date}} | ||
commit_sha: ${{steps.version.outputs.commit_sha}} | ||
|
||
build-ztm-cli-linux-x86_64: | ||
needs: set-release-version | ||
name: build-ztm-cli-linux-x86_64 | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Build | ||
id: build | ||
env: | ||
RELEASE_VERSION: ${{ needs.set-release-version.outputs.release_version }} | ||
ZTM_VERSION: ${{needs.set-release-version.outputs.release_version}} | ||
ZTM_COMMIT_SHA: ${{needs.set-release-version.outputs.commit_sha}} | ||
ZTM_COMMIT_DATE: ${{needs.set-release-version.outputs.commit_date}} | ||
run: | | ||
set -x | ||
./build.sh | ||
ls -al | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ztm-cli-${{needs.set-release-version.outputs.release_version}}-generic_linux-x86_64.tar.gz | ||
path: ztm-cli-${{needs.set-release-version.outputs.release_version}}-generic_linux-x86_64.tar.gz | ||
|
||
build-ztm-cli-linux-arm64: | ||
needs: set-release-version | ||
name: build-ztm-cli-linux-arm64 | ||
runs-on: [self-hosted, linux, ARM64] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Build | ||
id: build | ||
env: | ||
RELEASE_VERSION: ${{ needs.set-release-version.outputs.release_version }} | ||
ZTM_VERSION: ${{needs.set-release-version.outputs.release_version}} | ||
ZTM_COMMIT_SHA: ${{needs.set-release-version.outputs.commit_sha}} | ||
ZTM_COMMIT_DATE: ${{needs.set-release-version.outputs.commit_date}} | ||
run: | | ||
set -x | ||
./build.sh | ||
ls -al | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ztm-cli-${{needs.set-release-version.outputs.release_version}}-generic_linux-arm64.tar.gz | ||
path: ztm-cli-${{needs.set-release-version.outputs.release_version}}-generic_linux-arm64.tar.gz | ||
|
||
build-ztm-cli-macos-x64: | ||
needs: set-release-version | ||
name: build-ztm-cli-macos-x64 | ||
runs-on: macos-13 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Build | ||
id: build | ||
env: | ||
RELEASE_VERSION: ${{ needs.set-release-version.outputs.release_version }} | ||
ZTM_VERSION: ${{needs.set-release-version.outputs.release_version}} | ||
ZTM_COMMIT_SHA: ${{needs.set-release-version.outputs.commit_sha}} | ||
ZTM_COMMIT_DATE: ${{needs.set-release-version.outputs.commit_date}} | ||
run: | | ||
set -x | ||
./build.sh | ||
ls -al | ||
uname -m | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ztm-cli-${{needs.set-release-version.outputs.release_version}}-macos-x86_64.tar.gz | ||
path: ztm-cli-${{needs.set-release-version.outputs.release_version}}-macos-x86_64.tar.gz | ||
|
||
build-ztm-cli-macos-arm64: | ||
needs: set-release-version | ||
name: build-ztm-cli-macos-arm64 | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Build | ||
id: build | ||
env: | ||
RELEASE_VERSION: ${{ needs.set-release-version.outputs.release_version }} | ||
ZTM_VERSION: ${{needs.set-release-version.outputs.release_version}} | ||
ZTM_COMMIT_SHA: ${{needs.set-release-version.outputs.commit_sha}} | ||
ZTM_COMMIT_DATE: ${{needs.set-release-version.outputs.commit_date}} | ||
run: | | ||
set -x | ||
./build.sh | ||
ls -al | ||
uname -m | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ztm-cli-${{needs.set-release-version.outputs.release_version}}-macos-arm64.tar.gz | ||
path: ztm-cli-${{needs.set-release-version.outputs.release_version}}-macos-arm64.tar.gz | ||
|
||
build-ztm-cli-win-x64: | ||
needs: set-release-version | ||
name: build-ztm-cli-win-x64 | ||
runs-on: windows-latest | ||
defaults: | ||
run: | ||
shell: cmd | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Add msbuild to PATH | ||
uses: microsoft/setup-msbuild@v2 | ||
with: | ||
msbuild-architecture: x64 | ||
|
||
- uses: lukka/get-cmake@latest | ||
with: | ||
cmakeVersion: "~3.25.0" | ||
ninjaVersion: "^1.11.1" | ||
|
||
- name: Install NASM | ||
uses: ilammy/setup-nasm@v1 | ||
|
||
- name: Build | ||
id: build | ||
env: | ||
RELEASE_VERSION: ${{ needs.set-release-version.outputs.release_version }} | ||
ZTM_VERSION: ${{needs.set-release-version.outputs.release_version}} | ||
ZTM_COMMIT_SHA: ${{needs.set-release-version.outputs.commit_sha}} | ||
ZTM_COMMIT_DATE: ${{needs.set-release-version.outputs.commit_date}} | ||
run: | | ||
.\build.cmd | ||
dir | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ztm-cli-${{needs.set-release-version.outputs.release_version}}-win-x86_64.zip | ||
path: ztm-cli-${{needs.set-release-version.outputs.release_version}}-win-x86_64.zip | ||
|
||
build-libztm-android: | ||
needs: set-release-version | ||
name: build-libztm-android | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- uses: nttld/setup-ndk@v1 | ||
id: setup-ndk | ||
with: | ||
ndk-version: r26c | ||
|
||
- uses: seanmiddleditch/gha-setup-ninja@v4 | ||
id: setup-ninja | ||
with: | ||
version: 1.11.1 | ||
|
||
- name: Build | ||
id: build | ||
env: | ||
RELEASE_VERSION: ${{ needs.set-release-version.outputs.release_version }} | ||
ZTM_VERSION: ${{needs.set-release-version.outputs.release_version}} | ||
ZTM_COMMIT_SHA: ${{needs.set-release-version.outputs.commit_sha}} | ||
ZTM_COMMIT_DATE: ${{needs.set-release-version.outputs.commit_date}} | ||
BUILD_ZTM_SHARED: true | ||
NDK: "${{ steps.setup-ndk.outputs.ndk-path }}" | ||
run: | | ||
set -x | ||
./build.sh | ||
ls -al | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: libztm-${{needs.set-release-version.outputs.release_version}}-android.tar.gz | ||
path: libztm-${{needs.set-release-version.outputs.release_version}}-android.tar.gz | ||
|
||
create-release: | ||
name: create release | ||
runs-on: ubuntu-20.04 | ||
needs: | ||
- set-release-version | ||
- build-ztm-cli-linux-x86_64 | ||
- build-ztm-cli-linux-arm64 | ||
- build-ztm-cli-macos-x64 | ||
- build-ztm-cli-macos-arm64 | ||
- build-ztm-cli-win-x64 | ||
- build-libztm-android | ||
env: | ||
ZTM_VERSION: ${{needs.set-release-version.outputs.release_version}} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
|
||
- name: Check downloads | ||
run: | | ||
ls -alR | ||
- name: Create draft release | ||
id: create_release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
draft: true | ||
tag_name: ${{needs.set-release-version.outputs.release_version}} | ||
files: | | ||
ztm-cli-${{env.ZTM_VERSION}}-generic_linux-x86_64.tar.gz/ztm-cli-${{env.ZTM_VERSION}}-generic_linux-x86_64.tar.gz | ||
ztm-cli-${{env.ZTM_VERSION}}-generic_linux-arm64.tar.gz/ztm-cli-${{env.ZTM_VERSION}}-generic_linux-arm64.tar.gz | ||
ztm-cli-${{env.ZTM_VERSION}}-macos-x86_64.tar.gz/ztm-cli-${{env.ZTM_VERSION}}-macos-x86_64.tar.gz | ||
ztm-cli-${{env.ZTM_VERSION}}-macos-arm64.tar.gz/ztm-cli-${{env.ZTM_VERSION}}-macos-arm64.tar.gz | ||
ztm-cli-${{env.ZTM_VERSION}}-win-x64.zip/ztm-cli-${{env.ZTM_VERSION}}-win-x64.zip | ||
lib-ztm-${{env.ZTM_VERSION}}-android.tar.gz/libztm-${{env.ZTM_VERSION}}-android.tar.gz |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ bin/ | |
cli/version.json | ||
agent/version.json | ||
agent/gui | ||
version.env | ||
usr/ |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,27 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
check_version() { | ||
if [ `printf '%s\n%s' $1 $2 | sort -V | head -n1` = $1 ]; then | ||
echo $3 | ||
exit 1 | ||
fi | ||
} | ||
ZTM_DIR=$(cd "$(dirname "$0")" && pwd) | ||
|
||
check_version `node -v` 'v16' 'Require Node.js version 16 or above' | ||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | ||
export OS_NAME=generic_linux | ||
elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
export OS_NAME=macos | ||
fi | ||
|
||
ZTM_DIR=$(cd "$(dirname "$0")" && pwd) | ||
ZTM_BIN="$ZTM_DIR/bin/ztm" | ||
export OS_ARCH=$(uname -m) | ||
if [[ $OS_ARCH == "aarch64" ]] | ||
then | ||
export OS_ARCH=arm64 | ||
fi | ||
|
||
cd "$ZTM_DIR" | ||
build/deps.sh | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Prepare deps failed, exit..." | ||
exit 1 | ||
fi | ||
|
||
cd "$ZTM_DIR" | ||
build/gui.sh | ||
build/pipy.sh | ||
|
||
git submodule update --init | ||
|
||
cd "$ZTM_DIR/pipy" | ||
npm install --no-audit | ||
|
||
cd "$ZTM_DIR/gui" | ||
npm install --no-audit | ||
|
||
mkdir -p "$ZTM_DIR/bin" | ||
rm -f "$ZTM_BIN" | ||
cp -f "$ZTM_DIR/pipy/bin/pipy" "$ZTM_BIN" | ||
|
||
echo "The final product is ready at $ZTM_BIN" |
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
Oops, something went wrong.