-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathaction.yml
More file actions
81 lines (75 loc) · 2.73 KB
/
Copy pathaction.yml
File metadata and controls
81 lines (75 loc) · 2.73 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
name: 'Release Version'
description: 'Create new GitHub release using Conventional Commits'
icon: 'git-merge'
color: 'yellow'
inputs:
GITHUB_TOKEN:
description: 'GitHub Actions token with write permissions, see docs: https://docs.github.com/en/actions/security-guides/automatic-token-authentication'
required: false
ACTION_TYPE:
description: 'Which type of action to perform.'
required: true
type: choice
options:
- Release
- Validate
TAG_ONLY:
description: 'True if a Git tag should be created but not a GitHub release'
required: false
type: boolean
default: false
CONTAINS_BREAKING_CHANGE:
description: 'Whether the commit being validated contains a breaking change to the public facing API'
required: false
default: 'false'
outputs:
release_version:
description: "Release version in semantic format; e.g. 1.0.0"
value: ${{ steps.release.outputs.version }}
runs:
using: "composite"
steps:
- name: Download or Build Binary
shell: bash
run: |
BIN_DIR="${{ github.action_path }}/bin"
mkdir -p "$BIN_DIR"
# Derive the ref from the action's checkout path (last path component)
REF=$(basename "${{ github.action_path }}")
if echo "$REF" | grep -qE '^[0-9a-f]{7,40}$'; then
TAG=$(gh api "repos/$GITHUB_ACTION_REPOSITORY/tags" \
--jq ".[] | select(.commit.sha | startswith(\"$REF\")) | .name" 2>/dev/null | head -1)
[ -n "$TAG" ] && REF="$TAG"
fi
if gh release download "$REF" \
--repo "$GITHUB_ACTION_REPOSITORY" \
--pattern "Run" \
--output "$BIN_DIR/Run"; then
echo "Binary downloaded successfully for $REF"
chmod +x "$BIN_DIR/Run"
else
echo "Binary not available for $REF, falling back to swift build"
cd "${{ github.action_path }}" && swift build -c release
cp "${{ github.action_path }}/.build/release/Run" "$BIN_DIR/Run"
fi
env:
GH_TOKEN: ${{ inputs.GITHUB_TOKEN || github.token }}
- name: Validate
if: ${{ inputs.ACTION_TYPE == 'Validate' }}
shell: bash
run: |
"${{ github.action_path }}/bin/Run" validate \
--message "${{ github.event.pull_request.title }}" \
--contains-breaking-change ${{ inputs.CONTAINS_BREAKING_CHANGE }}
- name: Release
id: release
if: ${{ inputs.ACTION_TYPE == 'Release' }}
shell: bash
run: |
version=$("${{ github.action_path }}/bin/Run" increment \
--repository $GITHUB_REPOSITORY \
--sha $GITHUB_SHA \
--token ${{inputs.GITHUB_TOKEN}} \
--tag-only ${{inputs.TAG_ONLY}} \
)
echo "version=$version" >> $GITHUB_OUTPUT