-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathaction.yml
More file actions
189 lines (163 loc) · 7.1 KB
/
action.yml
File metadata and controls
189 lines (163 loc) · 7.1 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: "Release Rust Project Binaries as GitHub Releases"
author: "Dave Rolsky <autarch@urth.org>"
branding:
icon: home
color: gray-dark
description: |
This action provides tooling for releasing binaries from Rust projects as GitHub releases.
inputs:
executable-name:
description: |
The name of the executable. In most cases, this is just the name of your project, like `cross` or
`mise`. This is required.
required: true
release-tag-prefix:
description: |
The prefix for release tags. The default is "v", so that tags like "v1.2.3" trigger a
release.
default: "v"
target:
description: |
The rust target name, like "x86_64-unknown-linux-gnu". This is used to find the output of
`cargo build`. If this isn't provided, then this action will look for the build output under
`target/release`, instead of something like `target/x86_64-unknown-linux-gnu/release`.
Either this input or the `archive-name` input must be provided.
archive-name:
description: |
The name of the archive file to produce. This will contain the executable and any additional
files specified in the `files-to-package` input, if any. If this isn't given, then one will be
created based, starting with the `executable-name` and followed by elements from the `target`
input.
Either this input or the `target` input must be provided.
extra-files:
description: |
A newline separated list of additional files or globs to include in the archive files for a
release.
Defaults to the file specified by the `changes-file` input and any file matching `README*` in
the project root.
If you _do_ specify any files, then you will need to also list the changes file and README
explicitly if you want them to be included.
changes-file:
description: |
The name of the file that contains the changelog for this project. This will be used to
generate a description for the GitHub Release. The default is `Changes.md`.
default: "Changes.md"
working-directory:
description: |
The current working directory in which the Rust project is. It defaults to "." so the
current working directory.
default: "."
action-gh-release-parameters:
description: |
A JSON string containing parameters to pass to `softprops/action-gh-release@v2`. You can use
the `toJSON()` function in your action to make passing this easier.
default: "{}"
_force-release-for-testing:
description: |
This exists to let me test the release parts of this action.
outputs:
artifact-id:
description: |
This is the ID of the artifact created by this action.
value: ${{ steps.publish-release-artifact.outputs.artifact-id }}
artifact-url:
description: |
This is the URL of the artifact created by this action.
value: ${{ steps.publish-release-artifact.outputs.artifact-url }}
runs:
using: composite
steps:
- name: Show inputs
shell: bash
run: |
echo '${{ toJSON(inputs) }}'
- name: Add this action's path to PATH
shell: bash
run: echo "${{ github.action_path }}" >> $GITHUB_PATH
- name: Validate inputs
shell: bash
run: |
validate-inputs.py "${{ github.workspace }}"
env:
INPUTS_executable_name: ${{ inputs.executable_name }}
INPUTS_release_tag_prefix: ${{ inputs.release-tag-prefix }}
INPUTS_target: ${{ inputs.target }}
INPUTS_archive_name: ${{ inputs.archive-name }}
INPUTS_extra-files: ${{ inputs.extra-files }}
INPUTS_changes_file: ${{ inputs.changes-file }}
INPUTS_working_directory: ${{ inputs.working-directory }}
INPUTS_action_gh_release_parameters: ${{ inputs.action-gh-release-parameters }}
- name: Package as archive
id: package-archive
shell: bash
run: |
make-archive.py \
--executable-name "${{ inputs.executable-name }}" \
--target "${{ inputs.target }}" \
--archive-name "${{ inputs.archive-name }}" \
--changes-file "${{ inputs.changes-file }}" \
--extra-files "${{ inputs.extra-files }}" \
--working-directory "${{ inputs.working-directory }}"
- name: Generate SHA-256 checksum file (*nix)
shell: bash
run: |
set -e
set -x
cd ${{ inputs.working-directory }}
shasum --algorithm 256 \
"${{ steps.package-archive.outputs.archive-file }}" \
> "${{ steps.package-archive.outputs.archive-file }}.sha256"
if: runner.os != 'Windows'
- name: Install dos2unix and psutils on Windows
shell: powershell
run: |
choco install --ignore-checksums --limit-output dos2unix psutils
if: runner.os == 'Windows'
- name: Generate SHA-256 checksum file (Windows)
shell: powershell
run: |
cd ${{ inputs.working-directory }}
shasum --algorithm 256 `
"${{ steps.package-archive.outputs.archive-file }}" `
> "${{ steps.package-archive.outputs.archive-file }}.sha256"
dos2unix "${{ steps.package-archive.outputs.archive-file }}.sha256"
if: runner.os == 'Windows'
- name: Publish release artifact for run
id: publish-release-artifact
uses: actions/upload-artifact@v6
with:
name: ${{ steps.package-archive.outputs.archive-file }}
path: ${{ inputs.working-directory }}/${{ steps.package-archive.outputs.archive-file }}*
- name: Parse `action-gh-release-parameters` and set inputs for `softprops/action-gh-release`
id: action-gh-release-parameters
shell: bash
run: |
set -e
set -x
set -o pipefail
FAKE_TAG=""
if [ -n "${{ inputs._force-release-for-testing }}" ]; then
workflow_ref="${{ github.workflow_ref }}"
workflow_path="${workflow_ref%%@*}"
workflow_file=$(basename "$workflow_path")
timestamp=$( TZ=UTC git log -1 --format=%cd --date=format-local:%Y-%m-%dT%H-%M-%S )
FAKE_TAG="v-$timestamp-${{ github.ref_name }}-${{ github.sha }}-${{ github.run_number }}-$workflow_file"
fi
# This will get the inputs JSON from the `ACTION_GH_RELEASE_PARAMETERS` env var. This avoids
# any string interpolation issues, since the inputs will contain quotes.
parse-and-set-action-gh-release-parameters.py \
--working-directory "${{ inputs.working-directory }}" \
--archive-file "${{ steps.package-archive.outputs.archive-file }}" \
--changes-file "${{ inputs.changes-file }}" \
--fake-tag "$FAKE_TAG"
env:
ACTION_GH_RELEASE_PARAMETERS: ${{ inputs.action-gh-release-parameters }}
if:
( github.ref_type == 'tag' && startsWith( github.ref_name, inputs.release-tag-prefix ) ) ||
inputs._force-release-for-testing
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with: ${{ steps.action-gh-release-parameters.outputs }}
if:
( github.ref_type == 'tag' && startsWith( github.ref_name, inputs.release-tag-prefix ) ) ||
inputs._force-release-for-testing