This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
84 lines (82 loc) · 2.76 KB
/
action.yaml
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
name: 'guardian/action-sbt-release'
description: 'Run sbt-release command to publish to a signed release to maven'
inputs:
version:
description: "The version that should be released. If not provided will be taken from the tags"
type: string
default: ''
required: false
isSnapshot:
description: "Is this a snapshot (pre-release) version?"
type: boolean
default: true
fetchDepth:
description: "How many commits are required to find the tagged version? 0 fetches everything. See docs for actions/checkout"
default: 1
pgpSecret:
description: "base64 encoded PGP secret if neccessary for the SBT release process"
default: ''
required: false
pgpPassphrase:
description: "passphrase for the above key"
default: ''
required: false
sonatypeUsername:
default: ''
required: false
sonatypePassword:
default: ''
required: false
runs:
using: 'composite'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: ${{ inputs.fetchDepth }}
- uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 11
cache: sbt
- name: Use supplied version
if: ${{ inputs.version != '' }}
shell: bash
run: |
echo "VERSION=${{ inputs.version }}" >> "$GITHUB_ENV"
- name: Get version to publish as
if: ${{ inputs.version == '' }}
shell: bash
run: |
git describe --tags --exact-match HEAD || exit 1
VERSION=$(git describe --tags | cut -f2 -d"@")
if [[ ${VERSION:0:1} == "v" ]] ; then
VERSION=${VERSION:1}
fi
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
- name: Optionally set snapshot version
if: ${{ inputs.isSnapshot != 'false' }}
shell: bash
run: |
if [[ ${VERSION: -9} != "-SNAPSHOT" ]] ; then
echo "Version must end in -SNAPSHOT. Adding -SNAPSHOT suffix"
VERSION="$VERSION-SNAPSHOT"
fi
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
- name: Import PGP key if there is one
if: ${{ inputs.pgpSecret != '' }}
shell: bash
run: "echo $PGP_SECRET | base64 --decode | gpg --batch --import"
env:
PGP_SECRET: ${{ inputs.pgpSecret }}
PGP_PASSPHRASE: ${{ inputs.pgpPassphrase }}
- name: Run sbt release
shell: bash
run: |
export GPG_TTY=$(tty)
RELEASE_TYPE="${{ inputs.isSnapshot == 'true' && 'snapshot' || 'production' }}"
echo "Releasing version $VERSION Sonatype as $RELEASE_TYPE"
sbt -DRELEASE_TYPE=$RELEASE_TYPE "clean" "release cross release-version $VERSION with-defaults"
env:
PGP_PASSPHRASE: ${{ inputs.pgpPassphrase }}
SONATYPE_USERNAME: ${{ inputs.sonatypeUsername }}
SONATYPE_PASSWORD: ${{ inputs.sonatypePassword }}