-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e7c4c08
Showing
21 changed files
with
4,530 additions
and
0 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,148 @@ | ||
name: Ghost Rust Build and Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'release/**' | ||
tags: | ||
- 'v*' | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
rust_target: x86_64-unknown-linux-gnu | ||
asset_name: ghost-linux-x86_64 | ||
- os: macos-latest | ||
rust_target: x86_64-apple-darwin | ||
asset_name: ghost-macos-x86_64 | ||
- os: macos-latest | ||
rust_target: aarch64-apple-darwin | ||
asset_name: ghost-macos-arm64 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
target: ${{ matrix.rust_target }} | ||
override: true | ||
|
||
- name: Install OpenSSL (Ubuntu) | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y pkg-config libssl-dev | ||
- name: Install OpenSSL (macOS) | ||
if: matrix.os == 'macos-latest' | ||
run: | | ||
brew update | ||
brew install [email protected] | ||
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile | ||
export LDFLAGS="-L/usr/local/opt/[email protected]/lib" | ||
export CPPFLAGS="-I/usr/local/opt/[email protected]/include" | ||
export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig" | ||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-cargo- | ||
- name: Build | ||
run: cargo build --release --target ${{ matrix.rust_target }} | ||
|
||
- name: Create tar.gz archive | ||
run: | | ||
mkdir -p release | ||
cp target/${{ matrix.rust_target }}/release/ghost release/ | ||
cp README.md LICENSE release/ || true | ||
tar -czvf ${{ matrix.asset_name }}.tar.gz -C release . | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ matrix.asset_name }} | ||
path: | | ||
./target/${{ matrix.rust_target }}/release/ghost | ||
./${{ matrix.asset_name }}.tar.gz | ||
release: | ||
name: Create Release | ||
needs: build | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.ref, 'refs/tags/') | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Download all artifacts | ||
uses: actions/download-artifact@v3 | ||
|
||
- name: Display structure of downloaded files | ||
run: | | ||
echo "Current directory contents:" | ||
ls -R | ||
echo "Detailed file information:" | ||
find . -type f -exec file {} \; | ||
- name: Create Release and Upload Assets | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release create ${{ github.ref_name }} --generate-notes | ||
for dir in ghost-*-x86_64 ghost-*-arm64; do | ||
echo "Processing directory: $dir" | ||
if [ -d "$dir" ]; then | ||
if [ -f "$dir/target/${{ runner.os == 'Linux' && 'x86_64-unknown-linux-gnu' || (matrix.rust_target == 'aarch64-apple-darwin' && 'aarch64-apple-darwin') || 'x86_64-apple-darwin' }}/release/ghost" ]; then | ||
echo "Uploading $dir/target/${{ runner.os == 'Linux' && 'x86_64-unknown-linux-gnu' || (matrix.rust_target == 'aarch64-apple-darwin' && 'aarch64-apple-darwin') || 'x86_64-apple-darwin' }}/release/ghost" | ||
gh release upload ${{ github.ref_name }} "$dir/target/${{ runner.os == 'Linux' && 'x86_64-unknown-linux-gnu' || (matrix.rust_target == 'aarch64-apple-darwin' && 'aarch64-apple-darwin') || 'x86_64-apple-darwin' }}/release/ghost" --clobber | ||
else | ||
echo "ghost binary not found in $dir" | ||
fi | ||
else | ||
echo "$dir is not a directory" | ||
fi | ||
if [ -f "$dir/$dir.tar.gz" ]; then | ||
echo "Uploading $dir/$dir.tar.gz" | ||
gh release upload ${{ github.ref_name }} "$dir/$dir.tar.gz" --clobber | ||
else | ||
echo "$dir/$dir.tar.gz not found" | ||
fi | ||
done | ||
echo "## Available Binaries:" > release_notes.md | ||
echo "" >> release_notes.md | ||
for dir in ghost-*-x86_64 ghost-*-arm64; do | ||
echo "- [$dir (binary)](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/ghost)" >> release_notes.md | ||
echo "- [$dir.tar.gz](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/$dir.tar.gz)" >> release_notes.md | ||
done | ||
gh release edit ${{ github.ref_name }} --notes-file release_notes.md | ||
- name: Debug Info | ||
run: | | ||
echo "GitHub Ref: ${{ github.ref }}" | ||
echo "GitHub Event Name: ${{ github.event_name }}" | ||
echo "Is Tag: ${{ startsWith(github.ref, 'refs/tags/') }}" | ||
ls -R |
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,3 @@ | ||
/target | ||
.env | ||
.idea/ |
Oops, something went wrong.