-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
action.yml
159 lines (153 loc) · 5.83 KB
/
action.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: "release-plz"
author: "Marco Ieni"
description: "Update version and changelog based on semantic versioning and conventional commits"
inputs:
command:
description: "The release-plz command to run. Accepted values: `release-pr`, `release`. If unspecified, this action runs both these commands."
required: false
registry:
description: "Registry where the packages are stored. The registry name needs to be present in the Cargo config. If unspecified, crates.io is used."
required: false
config:
description: "Config file location. If not present, the default 'release-plz.toml' is used."
required: false
backend:
description: "Forge backend. Valid values: 'github', 'gitea'"
default: "github"
required: false
manifest_path:
description:
"Path to the Cargo.toml of the project you want to update. If not provided, release-plz will use the Cargo.toml of the
root directory. Both Cargo workspaces and single packages are supported."
required: false
project_manifest:
description: "Deprecated. Use `manifest_path` instead."
required: false
version:
description: "Release-plz version to use. (Default: `0.3.112`)."
default: "0.3.112"
required: false
token:
description: "Token used to publish to the cargo registry"
required: false
outputs:
# Useful for when https://github.com/release-plz/release-plz/issues/1029 is implemented.
# For now, it just returns an array with `pr` in it.
prs:
description: "The release PRs opened by release-plz. (Not useful for now. Use `pr` instead)"
value: ${{ steps.release-plz.outputs.prs }}
pr:
description: "The release PR opened by release-plz."
value: ${{ steps.release-plz.outputs.pr }}
releases:
description: "The JSON output of the `release` command."
value: ${{ steps.release-plz.outputs.releases }}
prs_created:
description: "Whether release-plz created any release PR."
value: ${{ steps.release-plz.outputs.prs_created }}
releases_created:
description: "Whether release-plz released any package."
value: ${{ steps.release-plz.outputs.releases_created }}
branding:
icon: "zap"
color: "yellow"
runs:
using: "composite"
steps:
- name: Install binaries
uses: taiki-e/install-action@v2
with:
tool: cargo-semver-checks@0.38, release-plz@${{ inputs.version }}
- name: Configure git user from GitHub token
uses: MarcoIeni/git-config@v0.1
- name: Run release-plz
id: release-plz
shell: bash
run: |
if [[ -n "${{ inputs.config }}" ]]
then
echo "using config from '${{ inputs.config }}'"
# Use arrays so that inputs can contain spaces
CONFIG_PATH=("--config" "${{ inputs.config }}")
else
CONFIG_PATH=()
fi
if [[ -n "${{ inputs.token }}" ]]
then
echo "using custom registry token'"
TOKEN=("--token" "${{ inputs.token }}")
else
TOKEN=()
fi
if [[ -n "${{ inputs.backend }}" ]]
then
echo "using backend '${{ inputs.backend }}'"
BACKEND=("--backend" "${{ inputs.backend }}")
else
BACKEND=()
fi
if [[ -n "${{ inputs.registry }}" ]]
then
echo "using registry '${{ inputs.registry }}'"
ALT_REGISTRY=("--registry" "${{ inputs.registry }}")
else
ALT_REGISTRY=()
fi
if [[ -n "${{ inputs.manifest_path }}" ]]
then
echo "using manifest path '${{ inputs.manifest_path }}'"
MANIFEST_PATH=("--manifest-path" "${{ inputs.manifest_path }}")
elif [[ -n "${{ inputs.project_manifest }}" ]]
then
echo "using manifest path '${{ inputs.project_manifest }}'"
MANIFEST_PATH=("--project-manifest" "${{ inputs.project_manifest }}")
else
MANIFEST_PATH=()
fi
if [[ -z "${{ inputs.command }}" || "${{ inputs.command }}" == "release-pr" ]]
then
echo "-- Running release-plz release-pr --"
release_pr_output=$(release-plz release-pr\
--git-token "${GITHUB_TOKEN}"\
--repo-url "https://github.com/${GITHUB_REPOSITORY}"\
"${CONFIG_PATH[@]}"\
"${ALT_REGISTRY[@]}"\
"${MANIFEST_PATH[@]}"\
"${BACKEND[@]}"\
-o json)
echo "release_pr_output: $release_pr_output"
prs=$(echo $release_pr_output | jq -c .prs)
echo "prs=$prs" >> "$GITHUB_OUTPUT"
prs_length=$(echo "$prs" | jq 'length')
if [ "$prs_length" != "0" ]; then
prs_created=true
first_pr=$(echo $prs | jq -c .[0])
else
prs_created=false
first_pr="{}"
fi
echo "pr=$first_pr" >> "$GITHUB_OUTPUT"
echo "prs_created=$prs_created" >> "$GITHUB_OUTPUT"
fi
if [[ -z "${{ inputs.command }}" || "${{ inputs.command }}" == "release" ]]
then
echo "-- Running release-plz release --"
release_output=$(release-plz release\
--git-token "${GITHUB_TOKEN}"\
"${CONFIG_PATH[@]}"\
"${ALT_REGISTRY[@]}"\
"${MANIFEST_PATH[@]}"\
"${BACKEND[@]}"\
"${TOKEN[@]}"\
-o json)
echo "release_output: $release_output"
releases=$(echo $release_output | jq -c .releases)
echo "releases=$releases" >> "$GITHUB_OUTPUT"
releases_length=$(echo "$releases" | jq 'length')
if [ "$releases_length" != "0" ]; then
releases_created=true
else
releases_created=false
fi
echo "releases_created=$releases_created" >> "$GITHUB_OUTPUT"
fi