Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
128 lines (123 loc) · 5.69 KB
/
Copy pathaction.yml
File metadata and controls
128 lines (123 loc) · 5.69 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: verwalter
description: Changeset-based versioning for single packages and monorepos. Runs one verwalter command.
inputs:
command:
description: "One of: check, changeset, plan, pr, release, publish, pre-release, status."
required: true
pr:
description: Pull request number for `check`. Defaults to the event's pull request.
default: ${{ github.event.pull_request.number }}
token:
description: GitHub token with contents and pull-requests write for `pr` and `release`. Ignored when `app-client-id` is set.
default: ${{ github.token }}
app-client-id:
description: Client ID of a GitHub App. With `app-private-key`, the action makes an installation token for this repository and uses it in place of `token`.
default: ""
app-private-key:
description: Private key of that GitHub App.
default: ""
version:
description: verwalter release to run. Defaults to the version this action was checked out at.
default: ""
dry-run:
description: Print every push, tag and GitHub write instead of doing it.
default: "false"
args:
description: Extra arguments passed through to verwalter.
default: ""
releases:
description: "`publish` only: the `releases` output of the `release` step. Only those packages are published. Without it, or with an empty list, every tagged package is, and the registry check skips the versions it has."
default: ""
outputs:
released:
description: "`release` only: true when at least one release was tagged, drafted or published."
value: ${{ steps.run.outputs.released }}
releases:
description: "`release` only: JSON list of {package, previous_version, version, tag, prerelease, first_release, status}, dependencies first."
value: ${{ steps.run.outputs.releases }}
published:
description: "`publish` only: JSON list of package names the command published."
value: ${{ steps.run.outputs.published }}
failed:
description: "`publish` only: JSON list of package names whose command failed."
value: ${{ steps.run.outputs.failed }}
blocked:
description: "`publish` only: JSON list of package names not run because a dependency failed."
value: ${{ steps.run.outputs.blocked }}
outcomes:
description: "`publish` only: JSON list of {package, version, tag, status, reason}."
value: ${{ steps.run.outputs.outcomes }}
runs:
using: composite
steps:
- name: Make GitHub App token
id: app
if: inputs.app-client-id != ''
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
client-id: ${{ inputs.app-client-id }}
private-key: ${{ inputs.app-private-key }}
- name: Install verwalter
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
CHECKOUT=$(grep -m1 '^version' "$GITHUB_ACTION_PATH/Cargo.toml" | cut -d'"' -f2)
VERSION=${VERSION:-$CHECKOUT}
case "$(uname -s)-$(uname -m)" in
Linux-x86_64) TARGET=x86_64-unknown-linux-gnu ;;
Linux-aarch64) TARGET=aarch64-unknown-linux-gnu ;;
Darwin-arm64) TARGET=aarch64-apple-darwin ;;
*) TARGET="" ;;
esac
DIR="$RUNNER_TEMP/verwalter-$VERSION"
if [ ! -x "$DIR/verwalter" ]; then
mkdir -p "$DIR"
# No release binary to download: build from the action's own
# checkout instead.
if [ -z "$TARGET" ] || ! gh release download "v$VERSION" --repo livekit/verwalter --pattern "verwalter-$TARGET.tar.gz" --output - | tar -xz -C "$DIR"; then
if [ "$VERSION" != "$CHECKOUT" ]; then
echo "::error::cannot download verwalter v$VERSION, and the action checkout is v$CHECKOUT to build from"
exit 1
fi
echo "::notice::building verwalter v$VERSION from the action checkout"
cargo build --release --locked --quiet --manifest-path "$GITHUB_ACTION_PATH/Cargo.toml" --target-dir "$RUNNER_TEMP/verwalter-target"
cp "$RUNNER_TEMP/verwalter-target/release/verwalter" "$DIR/"
fi
fi
echo "$DIR" >> "$GITHUB_PATH"
- name: Run verwalter ${{ inputs.command }}
id: run
shell: bash
env:
GH_TOKEN: ${{ steps.app.outputs.token || inputs.token }}
COMMAND: ${{ inputs.command }}
PR: ${{ inputs.pr }}
ARGS: ${{ inputs.args }}
DRY_RUN: ${{ inputs.dry-run }}
RELEASES: ${{ inputs.releases }}
DEFAULT_TOKEN: ${{ github.token }}
SERVER_URL: ${{ github.server_url }}
run: |
set -euo pipefail
# git pushes with the credentials of actions/checkout, which are
# github.token. Pushes made with github.token start no workflows, so
# point git at the other token: the empty value clears the header
# that checkout set.
if [ "$GH_TOKEN" != "$DEFAULT_TOKEN" ]; then
AUTH=$(printf 'x-access-token:%s' "$GH_TOKEN" | base64 | tr -d '\n')
echo "::add-mask::$AUTH"
export GIT_CONFIG_COUNT=2
export GIT_CONFIG_KEY_0="http.$SERVER_URL/.extraheader" GIT_CONFIG_VALUE_0=""
export GIT_CONFIG_KEY_1="http.$SERVER_URL/.extraheader" GIT_CONFIG_VALUE_1="AUTHORIZATION: basic $AUTH"
fi
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
if [ "$DRY_RUN" = "true" ]; then ARGS="$ARGS --dry-run"; fi
case "$COMMAND" in
check) verwalter check --pr "$PR" $ARGS ;;
publish) if [ -n "$RELEASES" ]; then verwalter publish --releases "$RELEASES" $ARGS; else verwalter publish $ARGS; fi ;;
*) verwalter "$COMMAND" $ARGS ;;
esac