Skip to content

Commit 2c190c7

Browse files
author
Jeff May
committed
Fix release workflow
- Add workflow_dispatch for manual releases - Don't automatically release on valid tag push (let ci workflow do it)
1 parent 278d348 commit 2c190c7

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

.creds

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"email": "[email protected]",
3+
"name": "Jeff May"
4+
}

.github/workflows/release.yml

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,47 @@
11
name: Release
22
on:
3-
push:
4-
branches: [main, v1]
5-
tags: ["*"]
3+
workflow_dispatch:
4+
inputs:
5+
tag:
6+
description: Version to release (auto-generate snapshot if empty)
7+
required: false
8+
type: string
69
jobs:
710
publish:
8-
runs-on: ubuntu-20.04
11+
runs-on: ubuntu-latest
912
steps:
10-
- uses: actions/[email protected]
13+
- name: Validate Custom Version
14+
id: validate
15+
if: github.event.inputs.tag != ''
16+
run: |
17+
version="${{ github.event.inputs.tag }}"
18+
if [[ "$version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
19+
echo "::set-output name=version::$version"
20+
echo "::debug::Version to release: '$version' releasing to GitHub and Sonatype."
21+
else
22+
echo "::error line=3::Version to release: '$version' is a NOT valid release version. It must match start with a 'v' and be separated by 3 dots (i.e. v*.*.*)."
23+
exit 1
24+
fi
25+
gh api /users/${{ github.actor }} | jq -M '{ email: .email, name: .name }' >> .creds
26+
echo "::set-output name=actor_name::$(jq -r .name < .creds)"
27+
echo "::set-output name=actor_email::$(jq -r .email < .creds)"
28+
rm .creds
29+
- uses: actions/checkout@v3
1130
with:
1231
fetch-depth: 0
32+
- uses: oleksiyrudenko/gha-git-credentials@v2-latest
33+
if: github.event.inputs.tag != ''
34+
with:
35+
global: true
36+
name: ${{ steps.validate.outputs.actor_name }}
37+
email: ${{ steps.validate.outputs.actor_email }}
38+
actor: ${{ github.actor }}
39+
token: ${{ secrets.GITHUB_TOKEN }}
40+
- name: Tag Release
41+
if: github.event.inputs.tag != ''
42+
run: |
43+
git tag -am "${{ steps.validate.outputs.version }}" ${{ steps.validate.outputs.version }}
44+
git push origin ${{ steps.validate.outputs.version }}
1345
- uses: olafurpg/setup-scala@v13
1446
- run: sbt ci-release
1547
env:

0 commit comments

Comments
 (0)