-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
62 lines (59 loc) · 1.7 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
name: 'gem-release'
description: 'Composite action to simplify gem release'
inputs:
host:
description: 'host to upload gems'
required: false
default: 'https://rubygems.org'
key:
description: 'Key name in credentials YAML config'
required: false
default: rubygems_api_key
gem-file:
description: 'Path to .gem file'
required: false
default: '*.gem'
api-key:
description: 'Rubygems API key'
required: false
default: ''
bearer-token:
description: 'Bearer token as alternative for API key'
required: false
default: ''
release-command:
description: 'Custom command to release gem'
required: false
type: string
default: ''
runs:
using: "composite"
steps:
- shell: bash
run: |
# validation
if [ "${{ inputs.api-key }}" = "" -a "${{ inputs.bearer-token }}" = "" ]; then
echo "Any of api-key or bearer-token must be provided"
exit 1
fi
if [ "${{ inputs.api-key }}" != "" -a "${{ inputs.bearer-token }}" != "" ]; then
echo "Both api-key and bearer-token cannot be used together"
exit 1
fi
- shell: bash
run: |
mkdir -p ~/.gem
envsubst << 'EOF' > ~/.gem/credentials
---
:${{ inputs.key }}: ${{ inputs.bearer-token && format('Bearer {0}', inputs.bearer-token) || inputs.api-key }}
EOF
chmod 0600 ~/.gem/credentials
- shell: bash
run: |
if [ '${{ inputs.release-command }}' != "" ]; then
${{ inputs.release-command }}
elif [ "${{ inputs.bearer-token }}" != "" ]; then
gem push --key ${{ inputs.key }} --host ${{ inputs.host }} ${{ inputs.gem-file }}
else
gem push ${{ inputs.gem-file }}
fi