Skip to content

Commit

Permalink
ci: add release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
engsr6982 committed Feb 8, 2025
1 parent 071c29a commit d2b13cc
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 12 deletions.
21 changes: 9 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
with:
fetch-depth: 0

- uses: xmake-io/github-action-setup-xmake@v1
# with:
# xmake-version: branch@master

- uses: actions/cache@v4
with:
path: |
Expand All @@ -39,10 +43,6 @@ jobs:
restore-keys: |
xmake-
- uses: xmake-io/github-action-setup-xmake@v1
# with:
# xmake-version: branch@master

- name: Set up Clang(Linux)
if: runner.os == 'Linux'
run: |
Expand Down Expand Up @@ -79,17 +79,14 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-22.04, windows-2022]

env:
platformStr: ${{ matrix.platform == 'windows-2022' && 'Windows' || 'Linux' }}
platform: ["Windows", "Linux"]

name: Package ${{ matrix.platform == 'windows-2022' && 'windows' || 'linux' }} platform dependencies
name: Package ${{ matrix.platform }} platform dependencies
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ github.event.repository.name }}-${{ env.platformStr }}-x64-${{ github.sha }}
name: ${{ github.event.repository.name }}-${{ matrix.platform }}-x64-${{ github.sha }}
path: bin/

- name: Download depends
Expand All @@ -114,7 +111,7 @@ jobs:
cp -r bin/* full/plugins/
cp -a deps/node_modules/. full/plugins/js_engine/node_modules/
if [ "${{ env.platformStr }}" == "Windows" ]; then
if [ "${{ matrix.platform }}" == "Windows" ]; then
cp deps/libnode.dll full/
cp deps/node.exe full/
else
Expand All @@ -124,7 +121,7 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-${{ env.platformStr }}-full-x64-${{ github.sha }}
name: ${{ github.event.repository.name }}-${{ matrix.platform }}-full-x64-${{ github.sha }}
include-hidden-files: true
path: |
full/
153 changes: 153 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
on:
release:
types:
- published

env:
LLVM_VERSION: 15
LIBNODE_VERSION: 22.12.0

jobs:
# 编译
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, windows-2022]

name: Build with ${{ matrix.os == 'windows-2022' && 'Win-MSVC' || 'Ubuntu-Clang' }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: xmake-io/github-action-setup-xmake@v1
# with:
# xmake-version: branch@master

- uses: actions/cache@v4
with:
path: |
~/AppData/Local/.xmake
key: xmake-${{ hashFiles('xmake.lua') }}
restore-keys: |
xmake-
- name: Set up Clang(Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update -y -q
sudo apt-get install -y -q lsb-release wget software-properties-common gnupg
sudo wget https://apt.llvm.org/llvm.sh
sudo chmod +x llvm.sh
sudo ./llvm.sh ${{env.LLVM_VERSION}}
sudo apt-get install -y -q libc++-${{env.LLVM_VERSION}}-dev libc++abi-${{env.LLVM_VERSION}}-dev
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang-${{env.LLVM_VERSION}} 100
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-${{env.LLVM_VERSION}} 100
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{env.LLVM_VERSION}} 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{env.LLVM_VERSION}} 100
sudo update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-${{env.LLVM_VERSION}} 100
sudo update-alternatives --install /usr/bin/ld ld /usr/bin/ld.lld-${{env.LLVM_VERSION}} 100
- run: |
xmake repo -u
- run: |
xmake f -a x64 -m release -v -y
- run: |
xmake -v -y
- uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-${{ runner.os }}-x64-${{ github.sha }}
path: |
bin/
# 发布 Changelog
update-release-notes:
outputs:
release_notes: ${{ steps.extract-release-notes.outputs.release_notes }}
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- id: extract-release-notes
uses: ffurrer2/extract-release-notes@v2

- uses: softprops/action-gh-release@v1
with:
body: |
${{ steps.extract-release-notes.outputs.release_notes }}
# 发布
pack-and-upload-to-release:
needs:
- build
- update-release-notes
permissions:
contents: write
strategy:
matrix:
platform: ["Windows", "Linux"]

name: Pack and upload to release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Download depends
run: |
curl -o bin-linux.zip -L https://github.com/IceBlcokMC/node/releases/download/v${{env.LIBNODE_VERSION}}/bin-linux.zip
curl -o bin-windows.zip -L https://github.com/IceBlcokMC/node/releases/download/v${{env.LIBNODE_VERSION}}/bin-windows.zip
curl -o node_modules.zip -L https://github.com/IceBlcokMC/node/releases/download/v${{env.LIBNODE_VERSION}}/node_modules.zip
- name: Unzip depends
run: |
mkdir deps
mkdir deps/node_modules
unzip -a -q bin-linux.zip -d deps/
unzip -a -q bin-windows.zip -d deps/
unzip -a -q node_modules.zip -d deps/node_modules/
- uses: actions/download-artifact@v4
with:
name: ${{ github.event.repository.name }}-${{ matrix.platform }}-x64-${{ github.sha }}
path: bin/

- name: Pack full
run: |
mkdir full
mkdir full/plugins
cp -r bin/* full/plugins/
cp -a deps/node_modules/. full/plugins/js_engine/node_modules/
if [ "${{ matrix.platform }}" == "Windows" ]; then
cp deps/libnode.dll full/
cp deps/node.exe full/
else
cp deps/libnode.so.127 full/
cp deps/node full/
fi
- run: |
cp CHANGELOG.md README.md LICENSE full/
cp CHANGELOG.md README.md LICENSE bin/
- run: |
zip -r ../${{ github.event.repository.name }}-${{ matrix.platform }}-x64.zip .
working-directory: bin
- run: |
zip -r ../${{ github.event.repository.name }}-${{ matrix.platform }}-full-x64.zip .
working-directory: full
- uses: softprops/action-gh-release@v1
with:
files: |
${{ github.event.repository.name }}-${{ matrix.platform }}-x64.zip
${{ github.event.repository.name }}-${{ matrix.platform }}-full-x64.zip
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.1.0-rc.1] - 2025-02-08

### Added

- Initial release.

0 comments on commit d2b13cc

Please sign in to comment.