-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2aa6dd
commit a7a87bd
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
tags: | ||
- v*.*.* | ||
|
||
jobs: | ||
pre-publish-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
submodules: true | ||
|
||
- name: Cache Cargo dependencies | ||
uses: Swatinem/rust-cache@3cf7f8cc28d1b4e7d01e3783be10a97d55d483c8 # v2.7.1 | ||
|
||
- name: Build | ||
run: cargo build --verbose | ||
- name: Run tests | ||
run: | | ||
cargo test --verbose -- --include-ignored | ||
cargo test --verbose --all-features -- --include-ignored | ||
- name: Run Clippy | ||
run: cargo clippy --all-targets | ||
- name: Run Format Check | ||
run: cargo fmt --check | ||
|
||
publish-crates: | ||
runs-on: ubuntu-latest | ||
needs: [pre-publish-test] | ||
env: | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: publish | ||
run: | | ||
publish_package () { | ||
VERSION=$(cargo metadata --no-deps --format-version=1 | jq -r ".packages[] | select(.name==\"$1\") | .version") | ||
VERSIONS=$(curl -s -XGET "https://crates.io/api/v1/crates/$1" | jq -r 'select(.versions != null) | .versions[].num') | ||
if echo "${VERSIONS}" | grep "${VERSION}" >/dev/null; then | ||
echo "$1 ${VERSION} has already been published" | ||
else | ||
sleep 15 | ||
cargo publish -p "$1" --all-features | ||
fi | ||
} | ||
publish_package "jlabel" | ||
sleep 5 | ||
publish_package "jlabel-question" | ||
create-release: | ||
name: Create Release | ||
permissions: | ||
contents: write | ||
needs: [publish-crates] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check Tag | ||
id: check-tag | ||
run: | | ||
if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
echo "Not prerelease" | ||
echo "prerelease=false" >> $GITHUB_OUTPUT | ||
else | ||
echo "Prerelease" | ||
echo "prerelease=true" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Create release | ||
uses: "marvinpinto/action-automatic-releases@latest" | ||
with: | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
prerelease: ${{ steps.check-tag.outputs.prerelease == 'true' }} |