-
Notifications
You must be signed in to change notification settings - Fork 36
70 lines (60 loc) · 2.88 KB
/
dep_cargo_publish.yml
File metadata and controls
70 lines (60 loc) · 2.88 KB
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
64
65
66
67
68
69
70
name: Publish Crates to Cargo Registry
on:
workflow_call:
inputs:
event_name:
description: 'The event that triggered the workflow. (pull_request, workflow_dispatch, workflow_call, push)'
type: string
required: true
default: 'pull_request'
jobs:
publish-hyperlight-wasm:
runs-on: [self-hosted, Linux, X64, "1ES.Pool=HL-Ubuntu-22.04-KVM", "JobId=publish-hyperlight-wasm-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"]
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Hyperlight setup
uses: hyperlight-dev/ci-setup-workflow@v1.8.0
with:
rust-toolchain: "1.89"
# github actions that run against PRs check out a ref to the PR merge branch
# we need to switch / create a branch for cargo ws to run late
- name: set-branch-for-PRs
if: ${{ inputs.event_name == 'pull_request' }}
run: |
git switch -c ${{ github.ref}}
- name: Setup minver and cargo-workspaces
run: |
cargo install cargo-workspaces
cargo install minver_rs
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.Name "${{ github.actor }}"
- name: Set crate versions
run: |
git fetch --tags || true
version=$(MINVER_TAG_PREFIX=v MINVER_AUTO_INCREMENT_LEVEL=Minor MINVER_PRERELEASE_IDENTIFIER=preview minver)
echo "Setting version to $version"
cargo ws version --force=hyperlight_* --no-git-commit --yes custom $version
echo "HYPERLIGHTWASM_VERSION=$version" >> "$GITHUB_ENV"
- name: Determine if we should publish crates
run: |
echo "github.ref=${{ github.ref }}"
echo "HYPERLIGHTWASM_VERSION=$HYPERLIGHTWASM_VERSION"
if [[ ${{ github.ref }} =~ 'refs/heads/release/' || ( ${{ github.ref }} == 'refs/heads/dev' && $HYPERLIGHTWASM_VERSION =~ '-preview' ) ]]
then
echo "Setting SHOULD_PUBLISH in GITHUB_ENV"
echo "SHOULD_PUBLISH=true" >> "$GITHUB_ENV"
fi
- name: list package contents
working-directory: src/hyperlight_wasm
run: cargo package --list --manifest-path ./Cargo.toml --allow-dirty
# allow-dirty is needed in the publish below because we are using the --no-git-commit option above to cover the case
# where no changes are made by cargo ws version because the version is already correct
# Run cargo package to perform publishing validation if this workflow
# is triggered by a pull-request
- name: Package hyperlight-wasm (dry-run)
if: ${{ inputs.event_name == 'pull_request' }}
working-directory: src/hyperlight_wasm
run: cargo package --manifest-path ./Cargo.toml --allow-dirty