fix . broken completion #12
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: Build | |
on: [push] | |
env: | |
# The project name specified in your Cargo.toml | |
PROJECT_NAME: cargotom | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
REPO: ${{ github.repository }} | |
jobs: | |
build: | |
# Set the job to run on the platform specified by the matrix below | |
runs-on: ${{ matrix.runner }} | |
# Define the build matrix for cross-compilation | |
strategy: | |
matrix: | |
include: | |
- name: x86_64-unknown-linux-gnu # linux-amd64 | |
runner: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
- name: x86_64-pc-windows-msvc # win-amd64 | |
runner: windows-latest | |
target: x86_64-pc-windows-msvc | |
- name: x86_64-apple-darwin # macos-amd64 | |
runner: macos-latest | |
target: x86_64-apple-darwin | |
- name: aarch64-apple-darwin # macos-arm64 | |
runner: macos-latest | |
target: aarch64-apple-darwin | |
# The steps to run for each matrix item | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: "${{ matrix.target }}" | |
- name: Setup Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Install libssl-dev on Linux | |
if: runner.os == 'Linux' | |
run: sudo apt-get update && sudo apt-get install -y libssl-dev | |
- name: Install openssl on macOS | |
if: runner.os == 'macOS' | |
run: | | |
brew install openssl@3 | |
echo 'export OPENSSL_DIR="$(brew --prefix openssl@3)"' >> $GITHUB_ENV | |
echo 'export PKG_CONFIG_PATH="$(brew --prefix openssl@3)/lib/pkgconfig"' >> $GITHUB_ENV | |
echo 'export PATH="$(brew --prefix openssl@3)/bin:$PATH"' >> $GITHUB_ENV | |
- name: Build Binary | |
run: cargo build --verbose --locked --release --target ${{ matrix.target }} | |
- name: Move Files | |
id: move | |
shell: bash | |
run: | | |
BIN_SUFFIX="" | |
if [[ "${{ matrix.runner }}" == "windows-latest" ]]; then | |
BIN_SUFFIX=".exe" | |
fi | |
# The built binary output location | |
BIN_OUTPUT="target/${{ matrix.target }}/release/${PROJECT_NAME}${BIN_SUFFIX}" | |
# Define a better name for the final binary | |
BIN_RELEASE="${PROJECT_NAME}-${{ matrix.name }}${BIN_SUFFIX}" | |
BIN_RELEASE_VERSIONED="${PROJECT_NAME}-${{ github.ref_name }}-${{ matrix.name }}${BIN_SUFFIX}" | |
mkdir ./builds | |
mv "${BIN_OUTPUT}" "./builds/${BIN_RELEASE}" | |
echo "file_name=${BIN_RELEASE}" >> $GITHUB_ENV | |
# Move the built binary where you want it | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.file_name }} | |
path: ./builds/${{ env.file_name }} | |
release: | |
permissions: | |
contents: write | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get version from Cargo.toml | |
id: get_version | |
run: echo "version=$(awk -F'"' '/\[package\]/ {p=1} p && /version/ {print $2; exit}' Cargo.toml)" >> $GITHUB_ENV | |
- name: Get latest release tag | |
id: get_latest_release | |
run: echo "latest_tag=$(curl -s https://api.github.com/repos/${{ github.repository }}/tags | jq -r '.[0].name // "0.0.0"')" >> $GITHUB_ENV | |
- name: Compare versions | |
id: compare_versions | |
run: | | |
IFS='.' read -ra v1 <<< "${{ env.version }}" | |
IFS='.' read -ra v2 <<< "${{ env.latest_tag }}" | |
if [ "${v1[0]}" -gt "${v2[0]}" ] || ([ "${v1[0]}" -eq "${v2[0]}" ] && [ "${v1[1]}" -gt "${v2[1]}" ]) || ([ "${v1[0]}" -eq "${v2[0]}" ] && [ "${v1[1]}" -eq "${v2[1]}" ] && [ "${v1[2]}" -gt "${v2[2]}" ]); then | |
mkdir ./builds | |
echo "greater=1" >> $GITHUB_ENV | |
else | |
echo "greater=0" >> $GITHUB_ENV | |
fi | |
- name: Download Artifacts | |
if: env.greater == 1 | |
uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
path: "./builds" | |
- name: Create release | |
if: env.greater == 1 | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ env.version }} | |
name: ${{ env.version }} | |
artifacts: "./builds/*" |