-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
131 lines (126 loc) · 5.48 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
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: "."
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 config
shell: bash
run: |
echo "release-tag-prefix = ${{ inputs.release-tag-prefix }}"
echo "executable-name = ${{ inputs.executable-name }}"
echo "target = ${{ inputs.target }}"
echo "archive-name = ${{ inputs.archive-name }}"
echo "extra-files = ${{ inputs.extra-files }}"
echo "changes-file = ${{ inputs.changes-file }}"
echo "working-directory = ${{ inputs.working-directory }}"
echo "github.ref = ${{ github.ref }}"
echo "github.ref_type = ${{ github.ref_type }}"
echo "matches release-tag-prefix = ${{ startsWith( github.ref_name, inputs.release-tag-prefix ) }}"
- name: Add this action's path to PATH
shell: bash
run: echo "${{ github.action_path }}" >> $GITHUB_PATH
- name: Package as archive
id: package-archive
shell: bash
run: |
make-archive.pl \
--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-basename }}" \
> "${{ steps.package-archive.outputs.archive-basename }}.sha256"
if: runner.os != 'Windows'
- name: Install dos2unix and psutils on Windows
shell: powershell
run: |
choco install --ignore-checksums 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-basename }}" `
> "${{ steps.package-archive.outputs.archive-basename }}.sha256"
dos2unix "${{ steps.package-archive.outputs.archive-basename }}.sha256"
if: runner.os == 'Windows'
- name: Publish release artifact for run
id: publish-release-artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.package-archive.outputs.archive-basename }}
path: ${{ inputs.working-directory }}/${{ steps.package-archive.outputs.archive-basename }}*
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
draft: true
# The trailing "*" should pick up the checksum file.
files: ${{ inputs.working-directory }}/${{ steps.package-archive.outputs.archive-basename }}*
body_path: ${{ inputs.working-directory }}/${{ inputs.changes-file }}
if: github.ref_type == 'tag' && startsWith( github.ref_name, inputs.release-tag-prefix )