publish crates without version increment: that is, as-is

This commit is contained in:
folex 2021-05-14 16:32:12 +03:00
parent eefa673b4b
commit 829f4d4e0c

View File

@ -2,8 +2,8 @@ name: "publish-release"
on: on:
push: push:
branches: # branches:
- "master" # - "master"
jobs: jobs:
npm-publish: npm-publish:
@ -26,7 +26,7 @@ jobs:
~/.cargo/bin ~/.cargo/bin
target target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain with wasm32-unknown-unknown - name: Install Rust toolchain
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
toolchain: nightly toolchain: nightly
@ -38,50 +38,26 @@ jobs:
command: update command: update
args: --aggressive args: --aggressive
### Calculate FINAL_VERSION - name: Install jq
- name: Install jq & sponge run: sudo apt-get update && sudo apt-get --yes --force-yes install jq
run: sudo apt-get update && sudo apt-get --yes --force-yes install jq moreutils
- name: Install cargo-show cargo-workspaces toml-cli - name: Install cargo-workspaces toml-cli
run: cargo install cargo-show cargo-workspaces toml-cli || true run: cargo install cargo-workspaces toml-cli || true
- name: Calculate the version
run: |
# install semver and add it to PATH
yarn global add semver
PATH="$(yarn global bin):$PATH"
CARGO_TOML="Cargo.toml"
# get package name from Cargo.toml
PKG_NAME="$(toml get "$CARGO_TOML" package.name | tr -d \")"
# get version from Cargo.toml
LOCAL_VERSION="$(toml get "$CARGO_TOML" package.version | tr -d \")"
# Define accumulator array variable
ALL_CRATES_VERSIONS=()
# For all crates in the workspace accumulate its max_version
for CRATE_NAME in $(cargo ws list)
do
CRATE_VERSION="$((cargo show --json "$CRATE_NAME" | jq -r .crate.max_stable_version) 2>/dev/null || true)"
ALL_CRATES_VERSIONS+=($CRATE_VERSION)
done
# Take the highest version of all
MAX_CRATES_VERSION="$(semver -p ${ALL_CRATES_VERSIONS[@]} | tail -n1 || true)"
# Increment patch octet of the highest version
NEXT_CRATE_VERSION="$(semver --increment patch "${MAX_CRATES_VERSION}" || true)"
# take the highest version
MAX_VERSION="$(semver "$NEXT_CRATE_VERSION" "$LOCAL_VERSION" | tail -n1)"
echo "FINAL_VERSION=$MAX_VERSION" | tee -a $GITHUB_ENV
echo "PKG_NAME=$PKG_NAME" | tee -a $GITHUB_ENV
### === Rust package release === ### === Rust package release ===
- name: Login to crates.io - name: Login to crates.io
run: cargo login ${{ secrets.CRATES_IO_TOKEN }} run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
- name: Save fluence's crate version to env
run: |
set -x
PKG_NAME=fluence
VERSION=$(cargo ws list -l | grep "$PKG_NAME"$ | head -n1 | awk '{ print $2 }')
echo "VERSION=$VERSION" | tee -a $GITHUB_ENV
echo "PKG_NAME=$PKG_NAME" | tee -a $GITHUB_ENV
- name: Publish to crates.io - name: Publish to crates.io
run: cargo ws publish --no-git-commit --allow-dirty --yes custom "${{ env.FINAL_VERSION }}" run: cargo ws publish --no-git-commit --from-git --skip-published --yes
### Create a pre-release ### Create a pre-release
- name: Create Release - name: Create Release
@ -90,9 +66,9 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
tag_name: ${{ env.FINAL_VERSION }} tag_name: ${{ env.VERSION }}
release_name: Fluence Rust SDK ${{ env.FINAL_VERSION }} release_name: Fluence Rust SDK ${{ env.VERSION }}
body: | body: |
- [${{ env.FINAL_VERSION }} @ crates.io](https://crates.io/crates/${{ env.PKG_NAME }}/${{ env.FINAL_VERSION }}) - [${{ env.VERSION }} @ crates.io](https://crates.io/crates/${{ env.PKG_NAME }}/${{ env.VERSION }})
draft: false draft: false
prerelease: true prerelease: false