fix: ci #91
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
name: CD | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
release-please: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
outputs: | |
envx_version: ${{ env.ENVX_VERSION }} | |
build: ${{ env.BUILD }} | |
steps: | |
- name: Release Please | |
uses: GoogleCloudPlatform/release-please-action@v3 | |
id: release | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
release-type: rust | |
- name: Set SemVer String | |
id: set-semver | |
if: steps.release.outputs.release_created == 'true' | |
run: | | |
echo "ENVX_VERSION=${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}" >> $GITHUB_ENV | |
echo "BUILD=true" >> $GITHUB_ENV | |
build-release: | |
name: Build Release | |
needs: [release-please] | |
if: needs.release-please.outputs.build == 'true' | |
permissions: | |
contents: write | |
runs-on: ${{ matrix.os }} | |
continue-on-error: true | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
- target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
# - target: i686-unknown-linux-musl | |
# os: ubuntu-latest | |
# install-musl: true | |
# - target: aarch64-unknown-linux-musl | |
# os: ubuntu-latest | |
# - target: arm-unknown-linux-musleabihf | |
# os: ubuntu-latest | |
- target: x86_64-apple-darwin | |
os: macOS-latest | |
- target: aarch64-apple-darwin | |
os: macOS-latest | |
- target: x86_64-pc-windows-msvc | |
os: windows-latest | |
# - target: i686-pc-windows-msvc | |
# os: windows-latest | |
- target: x86_64-pc-windows-gnu | |
os: windows-latest | |
# - target: i686-pc-windows-gnu | |
# os: windows-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: install system dependencies | |
run: sudo apt update && sudo apt install -y make libssl-dev pkg-config | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
- name: install musl | |
run: sudo apt install -y musl-tools musl-dev linux-headers-$(uname -r) | |
if: ${{ matrix.install-musl }} | |
- name: install wget and make | |
run: sudo apt install -y wget make | |
if: ${{ matrix.install-musl }} | |
- name: Install OpenSSL for x86 MUSL | |
run: | | |
sudo ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/x86_64-linux-musl/asm && ln -s /usr/include/asm-generic /usr/include/x86_64-linux-musl/asm-generic && ln -s /usr/include/linux /usr/include/x86_64-linux-musl/linux | |
sudo mkdir /musl | |
wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1f.tar.gz | |
tar zxf OpenSSL_1_1_1f.tar.gz | |
cd openssl-OpenSSL_1_1_1f/ | |
CC="musl-gcc -fPIE -pie -static -idirafter /usr/include/ -idirafter /usr/include/x86_64-linux-gnu/" ./Configure no-shared no-async --prefix=/musl --openssldir=/musl/ssl linux-x86_64 | |
make depend | |
make -j$(nproc) | |
sudo make install | |
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }} | |
- name: Build | |
run: cargo build --release --locked --target ${{ matrix.target }} | |
if: ${{ !matrix.install-musl }} | |
- name: Build (MUSL) | |
run: OPENSSL_DIR=/musl OPENSSL_STATIC=true PKG_CONFIG_ALLOW_CROSS=1 cargo build --release --locked --target ${{ matrix.target }} | |
if: ${{ matrix.install-musl }} | |
- name: Prepare binaries (zip) [Windows] | |
if: matrix.os == 'windows-latest' | |
run: | | |
cd target/${{ matrix.target }}/release | |
strip envx.exe | |
7z a ../../../envx-${{ needs.release-please.outputs.envx_version }}-${{ matrix.target }}.zip envx.exe | |
cd - | |
- name: Prepare binaries (tar) [Windows] | |
if: matrix.os == 'windows-latest' | |
run: | | |
cd target/${{ matrix.target }}/release | |
strip envx.exe | |
7z a -ttar archive.tar envx.exe | |
7z a -tgzip ../../../envx-${{ needs.release-please.outputs.envx_version }}-${{ matrix.target }}.tar.gz archive.tar | |
cd - | |
- name: Prepare binaries [-linux] | |
if: matrix.os != 'windows-latest' | |
run: | | |
cd target/${{ matrix.target }}/release | |
strip envx || true | |
tar czvf ../../../envx-${{ needs.release-please.outputs.envx_version }}-${{ matrix.target }}.tar.gz envx | |
cd - | |
- name: Upload release archive | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ needs.release-please.outputs.envx_version }} | |
files: envx-${{ needs.release-please.outputs.envx_version }}-${{ matrix.target }}* | |
# - name: Install cargo-deb | |
# if: matrix.target == 'x86_64-unknown-linux-musl' | |
# run: cargo install cargo-deb | |
# | |
# - name: Generate .deb package file | |
# if: matrix.target == 'x86_64-unknown-linux-musl' | |
# run: cargo deb --target x86_64-unknown-linux-musl --output envx-${{ needs.release-please.outputs.envx_version }}-amd64.deb | |
# | |
# - name: Upload .deb package file | |
# if: matrix.target == 'x86_64-unknown-linux-musl' | |
# uses: svenstaro/upload-release-action@v2 | |
# with: | |
# tag: ${{ needs.release-please.outputs.envx_version }} | |
# file: envx-${{ needs.release-please.outputs.envx_version }}-amd64.deb |