Update v0.0.18 #17
Workflow file for this run
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: Release_Build | |
env: | |
ProductName: rs_box | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
outputs: | |
UPLOAD_URL: ${{ steps.stepCreateRelease.outputs.upload_url }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Get latest tag | |
run: | | |
echo "LATEST_TAG=$(git tag | grep -v '^latest$' | sort -V | tail -n1)" >> $GITHUB_ENV | |
- name: Bump version and push tag | |
id: tag-version | |
uses: mathieudutour/[email protected] | |
with: | |
tag_prefix: "" | |
custom_tag: ${{ env.LATEST_TAG }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Step GitHub release | |
id: stepCreateRelease | |
uses: ncipollo/release-action@v1 | |
with: | |
skipIfReleaseExists: 'true' | |
tag: ${{ env.LATEST_TAG }} | |
name: ${{ env.LATEST_TAG }} | |
Build: | |
runs-on: ubuntu-latest | |
needs: release | |
steps: | |
- name: CheckOut | |
uses: actions/checkout@v4 | |
- name: Set APP_VERSION env | |
run: echo APP_VERSION=$(echo ${GITHUB_REF} | rev | cut -d'/' -f 1 | rev ) >> ${GITHUB_ENV} | |
- name: Login to crates.io | |
uses: actions-rs/cargo@v1 | |
with: | |
command: login | |
args: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
- name: Publish to crates.io | |
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
# - name: Upload binaries to release | |
# id: upload_file_to_release | |
# uses: george012/upload_github_release_assets_action@latest | |
# with: | |
# path: ./build/release/*.zip | |
# | |
# - name: Upload binaries to test | |
# id: upload_file_to_test | |
# uses: george012/upload_github_release_assets_action@latest | |
# with: | |
# path: ./build/test/*.zip | |
RemoveOldRelease: | |
runs-on: ubuntu-latest | |
needs: Build | |
steps: | |
- name: install github-cli | |
run: | | |
type -p curl >/dev/null || sudo apt install curl -y | |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ | |
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ | |
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ | |
&& sudo apt update \ | |
&& sudo apt install gh -y | |
- name: CheckOut | |
uses: actions/checkout@v4 | |
- name: Set APP_VERSION env | |
run: | | |
APP_VERSION=$(echo ${GITHUB_REF} | rev | cut -d'/' -f 1 | rev ) \ | |
function get_pre_del_tag { | |
local v_str=$1 | |
baseStr=$(echo $v_str | cut -d'.' -f1) | |
base=${baseStr//v/} | |
major=$(echo $v_str | cut -d'.' -f2) | |
minor=$(echo $v_str | cut -d'.' -f3) | |
if ((minor>0)); then | |
minor=$((minor-1)) | |
else | |
minor=999 | |
if ((major>0)); then | |
major=$((major-1)) | |
else | |
major=999 | |
if ((base>0)); then | |
base=$((base-1)) | |
else | |
echo "Error: Version cannot be decremented." | |
exit 1 | |
fi | |
fi | |
fi | |
pre_v_no="v${base}.${major}.${minor}" | |
echo $pre_v_no | |
} | |
APP_OLD_VERSION=$(get_pre_del_tag $(get_pre_del_tag $APP_VERSION)) | |
echo "Old version to remove: ${APP_OLD_VERSION}" | |
echo APP_OLD_VERSION=${APP_OLD_VERSION} >> ${GITHUB_ENV} | |
- name: Remove Old Release | |
run: | | |
gh release delete ${{ env.APP_OLD_VERSION }} -y | |
git push origin --delete ${{ env.APP_OLD_VERSION }} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |