forked from near/nearcore
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (55 loc) · 2.22 KB
/
near_crates_publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Near Crates Publish
on:
release:
types: [released]
workflow_dispatch:
inputs:
branch:
type: string
required: true
description: Branch name or tag to publish crates from
jobs:
publish-cargo-crates:
name: "Publish near-workspaces on crates.io https://crates.io/crates/near-workspaces"
runs-on: "ubuntu-22.04-16core"
environment: deploy
permissions:
contents: write # required for crates push
timeout-minutes: 30
steps:
- name: Checkout near/nearcore's ${{ github.event.inputs.branch }} branch
if: ${{ github.event_name == 'workflow_dispatch'}}
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch }}
- name: Checkout nearcore repository
if: ${{ github.event_name != 'workflow_dispatch'}}
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up git user
uses: fregante/setup-git-user@v2
- name: Check if version is already published
run: |
PACKAGE_NAME="near-primitives"
VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.metadata.workspaces.version')
PUBLISHED=$(curl -s https://crates.io/api/v1/crates/$PACKAGE_NAME/versions | jq -r '.versions[] | select(.num=="'"$VERSION"'") | .num')
if [ "$PUBLISHED" == "$VERSION" ]; then
echo "Version $VERSION of $PACKAGE_NAME is already published."
exit 1
fi
- name: Publish near-workspaces on crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
set -x
cargo install --git https://github.com/miraclx/cargo-workspaces --tag v0.3.0 cargo-workspaces
cargo ws publish --yes --allow-dirty --force '*' \
--no-git-commit --no-git-push --no-individual-tags --tag-prefix 'crates-' \
--tag-msg $$'crates.io snapshot\n---%{\n- %n - https://crates.io/crates/%n/%v}'
- name: Create tag on https://github.com/near/nearcore
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push --no-follow-tags https://github.com/near/nearcore.git tag 'crates-*'