Skip to content

fix: remove unnecessary release step and bump #17

fix: remove unnecessary release step and bump

fix: remove unnecessary release step and bump #17

Workflow file for this run

name: Complete workflow
on:
push:
branches:
- main
jobs:
create-version-branch:
runs-on: ubuntu-latest
outputs:
VERSION_UPDATED: ${{ steps.check-version.outputs.VERSION_UPDATED }}
VERSION: ${{ steps.check-version.outputs.VERSION }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for all branches and tags
token: ${{ secrets.GITHUB_TOKEN }} # Use GITHUB_TOKEN for authentication
- name: Check if Cargo.toml version has been updated
id: check-version
run: |
# Fetch the Cargo.toml from the main branch
git fetch origin main:Cargo.toml-main
# Extract version from both Cargo.toml files
VERSION_MAIN=$(grep "^version" Cargo.toml-main | cut -d '"' -f 2)
VERSION_CURRENT=$(grep "^version" Cargo.toml | cut -d '"' -f 2)
if [ "$VERSION_CURRENT" != "$VERSION_MAIN" ]; then
echo "Version has been updated to $VERSION_CURRENT"
echo "VERSION=$VERSION_CURRENT" >> $GITHUB_ENV
echo "VERSION=$VERSION_CURRENT" >> $GITHUB_OUTPUT
echo "VERSION_UPDATED=true" >> $GITHUB_OUTPUT
else
echo "Version has not been updated"
echo "VERSION_UPDATED=false" >> $GITHUB_OUTPUT
fi
- name: Update release branch with new version tag
if: steps.check-version.outputs.VERSION_UPDATED == 'true'
run: |
echo "Creating new branch with version $VERSION"
git config --global user.name 'GitHub Action'
git config --global user.email '[email protected]'
if git rev-parse --verify --quiet release; then
echo "Release branch exists. Checking it out."
git checkout release
git merge main --no-edit
else
echo "Creating new release branch."
git checkout -b release
fi
git tag v$VERSION
git push origin release
git push origin v$VERSION
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
needs: create-version-branch
if: needs.create-version-branch.outputs.VERSION_UPDATED == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install protobuf compiler
run: sudo apt-get install -y protobuf-compiler
- name: Publish to Crates.io
uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CRATES_API_KEY }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_API_KEY }}
build:
needs: create-version-branch
if: needs.create-version-branch.outputs.VERSION_UPDATED == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
target: x86_64-unknown-linux-gnu
- name: Install Cross-Compilation Tools
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
sudo apt-get install -y gcc-multilib g++-multilib
sudo apt-get install -y mingw-w64
- name: Build for x86_64 Linux
run: cargo build --release --target x86_64-unknown-linux-gnu
- name: Rename and move artifacts
run: |
mkdir -p artifacts
cp target/x86_64-unknown-linux-gnu/release/nnli artifacts/nnli-linux-x86_64
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: "v${{ needs.create-version-branch.outputs.VERSION }}"
files: ./artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}