Skip to content

Commit

Permalink
Set env vars for vcpkg and add a debug statement
Browse files Browse the repository at this point in the history
Clean up and optimize GH Actions
  • Loading branch information
dormant-user committed Feb 10, 2024
1 parent 4b94f19 commit a0e317a
Showing 1 changed file with 46 additions and 31 deletions.
77 changes: 46 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,22 @@ jobs:
outputs:
release-id: ${{ steps.create-release.outputs.release_id }}
release-flag: ${{ steps.set-release-flag.outputs.release_flag }}
pkg-name: ${{ steps.get-package-info.outputs.pkg_name }}
bin-name: ${{ steps.get-package-info.outputs.bin_name }}
steps:
- uses: actions/checkout@v3
- name: Get Package Name
id: get-package-info
run: |
name=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].name')
echo "Package Name: $name"
echo "pkg_name=$name" >> $GITHUB_ENV
pkg_name=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].name')
echo "Package Name: $pkg_name"
echo "pkg_name=$pkg_name" >> $GITHUB_ENV
echo "pkg_name=$pkg_name" >> "$GITHUB_OUTPUT"
bin_name=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].targets[0].name')
echo "Bin Name: $bin_name"
echo "bin_name=$bin_name" >> $GITHUB_ENV
echo "bin_name=$bin_name" >> "$GITHUB_OUTPUT"
shell: bash
- name: Set Release Flag # Release flag is set only for a push on main branch
if: github.event_name == 'push'
Expand Down Expand Up @@ -67,10 +76,10 @@ jobs:
echo "Release ID: $release_id"
echo "release_id=$release_id" >> "$GITHUB_OUTPUT"
shell: bash
- name: Build
- name: Build verbose
if: env.release == 'false'
run: cargo build --verbose
- name: Run tests
- name: Run tests verbose
if: env.release == 'false'
run: cargo test --verbose

Expand All @@ -83,29 +92,29 @@ jobs:
- release_for: Linux-x86_64
os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
bin: stream
name: RuStream-Linux-x86_64.tar.gz
bin: ${{ needs.release.outputs.bin-name }}
name: ${{ needs.release.outputs.pkg-name }}-Linux-x86_64.tar.gz
command: build

- release_for: Windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
bin: stream.exe
name: RuStream-Windows-x86_64.zip
bin: ${{ needs.release.outputs.bin-name }}.exe
name: ${{ needs.release.outputs.pkg-name }}-Windows-x86_64.zip
command: build

- release_for: macOS-x86_64
os: macOS-latest
target: x86_64-apple-darwin
bin: stream
name: RuStream-Darwin-x86_64.tar.gz
bin: ${{ needs.release.outputs.bin-name }}
name: ${{ needs.release.outputs.pkg-name }}-Darwin-x86_64.tar.gz
command: build

- release_for: RaspberryPi
os: ubuntu-20.04
target: arm-unknown-linux-gnueabihf
bin: stream
name: RuStream-RaspberryPi.tar.gz
bin: ${{ needs.release.outputs.bin-name }}
name: ${{ needs.release.outputs.pkg-name }}-RaspberryPi.tar.gz
command: build

name: Upload asset for ${{ matrix.platform.release_for }}
Expand All @@ -129,37 +138,43 @@ jobs:
cd \Tools
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
echo ("vcpkg_dir=" + $pwd) >> $env:GITHUB_ENV
.\bootstrap-vcpkg.bat
.\vcpkg.exe install openssl:x64-windows-static
$env:OPENSSL_DIR = 'C:\Tools\vcpkg\installed\x64-windows-static'
$env:OPENSSL_STATIC = 'Yes'
[System.Environment]::SetEnvironmentVariable('OPENSSL_DIR', $env:OPENSSL_DIR, [System.EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable('OPENSSL_STATIC', $env:OPENSSL_STATIC, [System.EnvironmentVariableTarget]::User)
- name: Build
run: |
if [ "${{ matrix.platform.os }}" == "windows-latest" ]; then
echo "Setting vcpkg env vars for OpenSSL in Windows"
export OPENSSL_DIR="${{ env.vcpkg_dir }}\installed\x64-windows-static"
export OPENSSL_STATIC="Yes"
export VCPKG_ROOT="${{ env.vcpkg_dir }}\installed\x64-windows-static"
fi
cargo build --release
shell: bash

- name: Run tests
run: |
if [ "${{ matrix.platform.os }}" == "windows-latest" ]; then
echo "Setting vcpkg env vars for OpenSSL in Windows"
export OPENSSL_DIR="${{ env.vcpkg_dir }}\installed\x64-windows-static"
export OPENSSL_STATIC="Yes"
export VCPKG_ROOT="${{ env.vcpkg_dir }}\installed\x64-windows-static"
fi
cargo test
shell: bash

- name: Copy artifacts to folder and compress non windows
if: ${{ matrix.platform.os != 'windows-latest' }}
- name: Copy Artifacts
run: |
mkdir -p rustream
cp target/release/${{ matrix.platform.bin }} rustream/${{ matrix.platform.bin }}
tar -zcvf ${{ matrix.platform.name }} rustream/
- name: Copy artifacts to folder and compress Windows
if: ${{ matrix.platform.os == 'windows-latest' }}
run: |
mkdir -p rustream
cp target/release/${{ matrix.platform.bin }} rustream/${{ matrix.platform.bin }}
Compress-Archive -DestinationPath ${{ matrix.platform.name }} -Path rustream/
if [ "${{ matrix.platform.os }}" == "windows-latest" ]; then
mkdir -p ${{ needs.release.outputs.pkg-name }}
cp target/release/${{ matrix.platform.bin }} ${{ needs.release.outputs.pkg-name }}/${{ matrix.platform.bin }}
Compress-Archive -DestinationPath ${{ matrix.platform.name }} -Path ${{ needs.release.outputs.pkg-name }}/
else
mkdir -p ${{ needs.release.outputs.pkg-name }}
cp target/release/${{ matrix.platform.bin }} ${{ needs.release.outputs.pkg-name }}/${{ matrix.platform.bin }}
tar -zcvf ${{ matrix.platform.name }} ${{ needs.release.outputs.pkg-name }}/
fi
- name: Upload Asset to Release
run: |
Expand All @@ -170,7 +185,7 @@ jobs:
shell: bash

publish-crate:
needs: release
needs: upload_assets
if: needs.release.outputs.release-flag == 'true'
runs-on: ubuntu-latest
steps:
Expand Down

0 comments on commit a0e317a

Please sign in to comment.