Skip to content

Remove python clinginess and pyo3 dependency #23

Remove python clinginess and pyo3 dependency

Remove python clinginess and pyo3 dependency #23

Workflow file for this run

name: Build and upload artifact for Linux
on:
workflow_dispatch:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
release-id: ${{ steps.create-release.outputs.release_id }}
pkg-name: ${{ steps.get-package-info.outputs.pkg_name }}
bin-name: ${{ steps.get-package-info.outputs.bin_name }}
steps:
- uses: actions/checkout@v4
- name: Get Package Name
id: get-package-info
run: |
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[] | select(.kind[] == "bin" or .crate_types[] == "bin") | .name')
echo "Bin Name: $bin_name"
echo "bin_name=$bin_name" >> $GITHUB_ENV
echo "bin_name=$bin_name" >> "$GITHUB_OUTPUT"
shell: bash
- name: Create New Release
id: create-release
run: |
extn="$(date +%s)"
release_tag="v1-linux-prerelease-${extn}"
cargo_prerelease=("alpha" "beta" "rc")
prerelease=true
commit_msg="Release compiled executable for $release_tag"
release_data="{\"tag_name\":\"$release_tag\",\"name\":\"$release_tag\",\"body\":\"$commit_msg\",\"draft\":false,\"prerelease\":$prerelease}"
response=$(curl -X POST -H "Authorization: token ${{ secrets.GIT_TOKEN }}" \
-d "$release_data" \
"https://api.github.com/repos/${{ github.repository }}/releases")
release_id=$(echo $response | jq -r .id)
echo "Release ID: $release_id"
echo "release_id=$release_id" >> "$GITHUB_OUTPUT"
shell: bash
upload_assets:
needs: release
strategy:
matrix:
platform:
- release_for: Linux-x86_64
os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
bin: ${{ needs.release.outputs.bin-name }}
name: ${{ needs.release.outputs.pkg-name }}-Linux-x86_64.tar.gz
command: build
name: Upload asset for ${{ matrix.platform.release_for }}
runs-on: ${{ matrix.platform.os }}
permissions:
contents: write
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Update Rust
# print it with style
run: |
printf '*%.0s' {1..60} && printf "\n"
echo "Existing rust version: $(rustc --version)"
printf '*%.0s' {1..60} && printf "\n\n"
rustup update && printf "\n"
printf '*%.0s' {1..60} && printf "\n"
echo "Updated rust version: $(rustc --version)"
printf '*%.0s' {1..60} && printf "\n"
- name: Install binary prerequisites
run: |
sudo apt-get install libssl-dev python3.9 libpython3.9-dev
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH
- name: Build and test
run: |
cargo build --release
cargo test
shell: bash
- name: Verify Library Paths
run: ldd ./target/release/${{ matrix.platform.bin }}
- name: Copy Artifacts
run: |
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 }}/
shell: bash
- name: Upload Asset to Release
run: |
curl -X POST -H "Authorization: token ${{ secrets.GIT_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"${{ matrix.platform.name }}" \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ needs.release.outputs.release-id }}/assets?name=${{ matrix.platform.name }}"
shell: bash