Skip to content

fix release workflow #162

fix release workflow

fix release workflow #162

name: Draft Nightly Nanocl
on:
push:
branches:
- "release/nightly/bin/nanocl/*"
pull_request:
branches:
- "release/nightly/bin/nanocl/*"
types: [opened, synchronize]
env:
CARGO_TERM_COLOR: always
jobs:
release_nanocl_bin_linux:
runs-on: ubuntu-latest
container: rust:1.82.0-alpine3.20
steps:
- name: Install dependencies
run: |
apk add --update alpine-sdk musl-dev g++ make libpq-dev openssl-dev git perl build-base dpkg pandoc github-cli bash
rustup target add x86_64-unknown-linux-musl
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/checkout@v4
# Extract branch info
- name: Set info
run: |
echo "CHANNEL=$(echo ${GITHUB_REF} | awk -F/ '{print $4}')" >> $GITHUB_ENV
echo "NANOCL_CHANNEL=$(echo ${GITHUB_REF} | awk -F/ '{print $4}')" >> $GITHUB_ENV
echo "BINARY_NAME=$(echo ${GITHUB_REF} | awk -F/ '{print $6}')" >> $GITHUB_ENV
echo "VERSION=$(echo ${GITHUB_REF} | awk -F/ '{print $7}')" >> $GITHUB_ENV
# Print info for debug
- name: Fix git permission
run: |
git config --global --add safe.directory /__w/nanocl/nanocl
- name: Print Info
run: |
echo $BRANCH_NAME
echo $BINARY_NAME
echo $CHANNEL
echo $VERSION
# Package nanocl into a .deb
- name: Package
run: |
export RUSTFLAGS="-C target-feature=+crt-static"
./scripts/release_nanocl.sh
- name: Test if release already exists
id: release-exists
continue-on-error: true
run: gh release view $BINARY_NAME-$VERSION-$CHANNEL
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
- name: Create new draft release
if: steps.release-exists.outcome == 'failure' && steps.release-exists.conclusion == 'success'
run: |
gh release create -d \
$BINARY_NAME-$VERSION-$CHANNEL \
-t $BINARY_NAME-$VERSION-$CHANNEL \
-F ./bin/$BINARY_NAME/changelog.md \
release/debian/${BINARY_NAME}_${VERSION}_amd64.deb#nanocl_amd64.deb \
release/${BINARY_NAME}_${VERSION}_linux_amd64.tar.gz#nanocl_linux_amd64.tar.gz \
--target ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
- name: Update draft release
if: steps.release-exists.outcome == 'success' && steps.release-exists.conclusion == 'success'
run: |
gh release delete-asset -y \
$BINARY_NAME-$VERSION-$CHANNEL \
${BINARY_NAME}_${VERSION}_amd64.deb || true
gh release delete-asset -y \
$BINARY_NAME-$VERSION-$CHANNEL \
${BINARY_NAME}_${VERSION}_linux_amd64.tar.gz || true
gh release upload \
$BINARY_NAME-$VERSION-$CHANNEL \
release/debian/${BINARY_NAME}_${VERSION}_amd64.deb#nanocl_amd64.deb
gh release upload \
$BINARY_NAME-$VERSION-$CHANNEL \
release/${BINARY_NAME}_${VERSION}_linux_amd64.tar.gz#nanocl_linux_amd64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
release_nanocl_bin_mac:
runs-on: macOS-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.82.0-aarch64-apple-darwin
- name: Set info
run: |
echo "CHANNEL=$(echo ${GITHUB_REF} | awk -F/ '{print $4}')" >> $GITHUB_ENV
echo "NANOCL_CHANNEL=$(echo ${GITHUB_REF} | awk -F/ '{print $4}')" >> $GITHUB_ENV
echo "BINARY_NAME=$(echo ${GITHUB_REF} | awk -F/ '{print $6}')" >> $GITHUB_ENV
echo "VERSION=$(echo ${GITHUB_REF} | awk -F/ '{print $7}')" >> $GITHUB_ENV
- name: Print Info
run: |
echo $BRANCH_NAME
echo $BINARY_NAME
echo $CHANNEL
echo $VERSION
- name: Install dependencies
run: |
brew install openssl
brew link --force openssl
brew install libpq
brew link --force libpq
- name: Package
run: |
export RUSTFLAGS="-C target-feature=+crt-static -L /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"
export PQ_LIB_DIR="$(brew --prefix libpq)/lib"
cargo build --release --target aarch64-apple-darwin --features vendored --features release --bin $BINARY_NAME
mkdir -p release/mac
mkdir -p release/mac/bin
mkdir -p release/mac/share/man/man1
# Generate man pages
for file in ./bin/nanocl/target/man/*; do
file_name=$(basename "${file}")
gzip <"$file" >release/mac/share/man/man1/"$file_name".gz
done
cp target/aarch64-apple-darwin/release/$BINARY_NAME release/mac/bin/$BINARY_NAME
tar -czf release/${BINARY_NAME}_${VERSION}_mac_aarch64.tar.gz -C release/mac .
- name: Test if release already exists
id: release-exists
continue-on-error: true
run: gh release view $BINARY_NAME-$VERSION-$CHANNEL
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
- name: Create new draft release
if: steps.release-exists.outcome == 'failure' && steps.release-exists.conclusion == 'success'
run: |
gh release create -d \
$BINARY_NAME-$VERSION-$CHANNEL \
-t $BINARY_NAME-$VERSION-$CHANNEL \
-F ./bin/$BINARY_NAME/changelog.md \
release/${BINARY_NAME}_${VERSION}_mac_aarch64.tar.gz#nanocl_mac_aarch64.tar.gz \
--target ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
- name: Update draft release
if: steps.release-exists.outcome == 'success' && steps.release-exists.conclusion == 'success'
run: |
gh release delete-asset -y \
$BINARY_NAME-$VERSION-$CHANNEL \
${BINARY_NAME}_${VERSION}_mac_aarch64.tar.gz || true
gh release upload \
$BINARY_NAME-$VERSION-$CHANNEL \
release/${BINARY_NAME}_${VERSION}_mac_aarch64.tar.gz#nanocl_mac_aarch64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
release_nanocl_bin_windows:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.82.0-x86_64-pc-windows-msvc
- name: Set info
run: |
$GITHUB_REF = "${{ github.ref }}"
$CHANNEL = ($GITHUB_REF -split "/")[3]
$NANOCL_CHANNEL = $CHANNEL
$BINARY_NAME = ($GITHUB_REF -split "/")[5]
$VERSION = ($GITHUB_REF -split "/")[6]
Add-Content -Path $env:GITHUB_ENV -Value "CHANNEL=$CHANNEL"
Add-Content -Path $env:GITHUB_ENV -Value "NANOCL_CHANNEL=$NANOCL_CHANNEL"
Add-Content -Path $env:GITHUB_ENV -Value "BINARY_NAME=$BINARY_NAME"
Add-Content -Path $env:GITHUB_ENV -Value "VERSION=$VERSION"
- name: Print Info
run: |
Write-Output "BRANCH_NAME=$env:BRANCH_NAME"
Write-Output "BINARY_NAME=$env:BINARY_NAME"
Write-Output "CHANNEL=$env:CHANNEL"
Write-Output "VERSION=$env:VERSION"
- name: Install dependencies
run: |
vcpkg integrate install
vcpkg install openssl:x64-windows libpq:x64-windows
Copy-Item C:\vcpkg\installed\x64-windows\bin\libcrypto-3-x64.dll C:\vcpkg\installed\x64-windows\bin\libcrypto.dll
Copy-Item C:\vcpkg\installed\x64-windows\bin\libssl-3-x64.dll C:\vcpkg\installed\x64-windows\bin\libssl.dll
Get-ChildItem C:\vcpkg\installed\x64-windows\bin
Get-ChildItem C:\vcpkg\installed\x64-windows\lib
- name: Package
run: |
$env:RUSTFLAGS="-C target-feature=+crt-static -LC:\vcpkg\installed\x64-windows\lib"
cargo build --release --target x86_64-pc-windows-msvc --features vendored --features release --bin $env:BINARY_NAME
mkdir -p release/windows/bin
ls target/x86_64-pc-windows-msvc/release
cp target/x86_64-pc-windows-msvc/release/$env:BINARY_NAME.exe release/windows/bin/$env:BINARY_NAME.exe
tar -czf release/$env:BINARY_NAME_$env:VERSION_windows_amd64.tar.gz -C release/windows .
- name: Test if release already exists
id: release-exists
continue-on-error: true
run: gh release view $env:BINARY_NAME-$env:VERSION-$env:CHANNEL
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
- name: Create new draft release
if: steps.release-exists.outcome == 'failure' && steps.release-exists.conclusion == 'success'
run: |
gh release create -d `
$env:BINARY_NAME-$env:VERSION-$env:CHANNEL `
-t $env:BINARY_NAME-$env:VERSION-$env:CHANNEL `
-F ./bin/$env:BINARY_NAME/changelog.md `
release/$env:BINARY_NAME_$env:VERSION_windows_amd64.tar.gz#nanocl_windows_amd64.tar.gz `
--target ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
- name: Update draft release
if: steps.release-exists.outcome == 'success' && steps.release-exists.conclusion == 'success'
run: |
gh release delete-asset -y `
$env:BINARY_NAME-$env:VERSION-$env:CHANNEL `
$env:BINARY_NAME_$env:VERSION_windows_amd64.tar.gz || true
gh release upload `
$env:BINARY_NAME-$env:VERSION-$env:CHANNEL `
release/$env:BINARY_NAME_$env:VERSION_windows_amd64.tar.gz#nanocl_windows_amd64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}