-
Notifications
You must be signed in to change notification settings - Fork 3
105 lines (90 loc) · 2.89 KB
/
Copy pathrelease-github.yml
File metadata and controls
105 lines (90 loc) · 2.89 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Release GitHub
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
tag:
description: 'Tag to create release for'
required: true
type: string
permissions:
contents: write
jobs:
release:
name: Create GitHub Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Determine tag
id: tag
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_TAG: ${{ inputs.tag }}
run: |
if [[ "$EVENT_NAME" == "push" ]]; then
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "tag=$INPUT_TAG" >> $GITHUB_OUTPUT
fi
- name: Wait for release workflows
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
WORKFLOWS="release-go release-typescript release-ruby release-kotlin release-swift"
MAX_WAIT=1800
POLL_INTERVAL=30
ELAPSED=0
for WORKFLOW in $WORKFLOWS; do
echo "Waiting for ${WORKFLOW}..."
while [ $ELAPSED -lt $MAX_WAIT ]; do
STATUS=$(gh run list --workflow="${WORKFLOW}.yml" --limit=1 --json headSha,conclusion -q ".[0] | select(.headSha == \"$GITHUB_SHA\") | .conclusion")
if [[ "$STATUS" == "success" ]]; then
echo " ${WORKFLOW}: success"
break
elif [[ "$STATUS" == "failure" ]]; then
echo "::error::${WORKFLOW} failed"
exit 1
fi
sleep $POLL_INTERVAL
ELAPSED=$((ELAPSED + POLL_INTERVAL))
done
if [ $ELAPSED -ge $MAX_WAIT ]; then
echo "::error::Timed out waiting for ${WORKFLOW}"
exit 1
fi
done
- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.tag.outputs.tag }}
EVENT_NAME: ${{ github.event_name }}
run: |
VERSION="${TAG#v}"
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
DRAFT="--draft"
else
DRAFT=""
fi
gh release create "$TAG" $DRAFT --generate-notes --title "$TAG" --notes-start-tag "$TAG" --notes "## Installation
### Go
\`\`\`
go get github.com/basecamp/fizzy-sdk/go@${TAG}
\`\`\`
### TypeScript
\`\`\`
npm install @basecamp/fizzy-sdk@${VERSION}
\`\`\`
### Ruby
\`\`\`
gem install fizzy-sdk -v ${VERSION}
\`\`\`
### Kotlin
\`\`\`kotlin
implementation(\"com.basecamp:fizzy-sdk:${VERSION}\")
\`\`\`
### Swift
\`\`\`swift
.package(url: \"https://github.com/basecamp/fizzy-sdk.git\", from: \"${VERSION}\")
\`\`\`
"