Repository navigation
73 lines (68 loc) · 2.22 KB
/
Copy pathpublish.yml
File metadata and controls
73 lines (68 loc) · 2.22 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
71
72
73
name: Publish crates
on:
workflow_dispatch:
inputs:
version:
description: 'Workspace version to publish'
required: true
default: '0.8.10'
type: string
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry and build artifacts
uses: Swatinem/rust-cache@v2.9.3
with:
shared-key: crates-publish
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
clang \
libclang-dev \
libwayland-dev \
wayland-protocols \
libxkbcommon-dev \
libegl-dev \
libgles-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libswresample-dev \
libswscale-dev \
pkg-config \
curl
- name: Verify requested version
env:
REQUESTED_VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
version=$(cargo metadata --no-deps --format-version 1 | jq -re '.packages[] | select(.name=="wallr") | .version')
test "$version" = "$REQUESTED_VERSION"
- name: Publish workspace crates
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
REQUESTED_VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
test -n "$CARGO_REGISTRY_TOKEN" || { echo "CARGO_REGISTRY_TOKEN is empty" >&2; exit 1; }
publish_if_missing() {
local crate="$1"
local index_path="wa/ll/${crate}"
local index
index="$(curl --silent --show-error --fail "https://index.crates.io/${index_path}")"
if grep -Fq "\"vers\":\"${REQUESTED_VERSION}\"" <<<"$index"; then
echo "$crate ${REQUESTED_VERSION} is already published; skipping"
else
cargo publish -p "$crate" --locked
sleep 30
fi
}
publish_if_missing wallr-common
publish_if_missing wallr-core
publish_if_missing wallr