Skip to content

Commit 74d0cb0

Browse files
authored
Add release logic to CI workflow (#138)
This hijacks the existing workflow to also do releases only when manually dispatched with a tag. Primarily done this way to not duplicate all logic. Signed-off-by: Keith Smiley <[email protected]>
1 parent 0f74c10 commit 74d0cb0

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

.github/generate-notes.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
readonly swift_version=$1
6+
readonly macos_archive=$2
7+
8+
readonly upstream_url="https://github.com/swiftlang/llvm-project/releases/tag/swift-$swift_version-RELEASE"
9+
10+
macos_sha=$(shasum -a 256 "$macos_archive")
11+
12+
cat <<EOF
13+
The binary included with this release was built against Swift $swift_version at [this tag]($upstream_url).
14+
15+
sha256:
16+
\`\`\`
17+
$macos_sha
18+
\`\`\`
19+
EOF

.github/workflows/test.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ on:
22
push:
33
branches: [main]
44
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
tag:
8+
description: 'The new version to tag, ex: 1.0.5'
9+
required: true
10+
type: string
511

612
name: Continuous integration
713

@@ -73,6 +79,41 @@ jobs:
7379
run: |
7480
PATH=$PWD/llvm/build/bin:$PATH ./tests/run.sh
7581
82+
- name: "index-import: archive"
83+
run: |
84+
cd build
85+
COPYFILE_DISABLE=1 tar czvf index-import.tar.gz absolute-unit index-import
86+
87+
- name: "index-import: upload"
88+
uses: actions/upload-artifact@v4
89+
with:
90+
path: build/index-import.tar.gz
91+
92+
create-release:
93+
name: Create release
94+
needs: build
95+
runs-on: ubuntu-22.04
96+
if: ${{ github.event_name == 'workflow_dispatch' }}
97+
steps:
98+
- name: Check out source code
99+
uses: actions/checkout@v4
100+
101+
- name: Download index-import artifact
102+
uses: actions/download-artifact@v4
103+
104+
- name: Create release
105+
run: |
106+
set -euo pipefail
107+
108+
macos_archive="index-import.tar.gz"
109+
./.github/generate-notes.sh "$SWIFT_VERSION" "$macos_archive" | tee notes.md
110+
cat notes.md
111+
echo "would have called" gh release create "$TAG" --title "$TAG" --target "$GITHUB_REF_NAME" --notes-file notes.md "$macos_archive"
112+
env:
113+
TAG: ${{ inputs.tag }}
114+
SWIFT_VERSION: ${{ env.SWIFT_VERSION }}
115+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
76117
# For local development, use the playground at
77118
# https://rhysd.github.io/actionlint/
78119
actionlint:

0 commit comments

Comments
 (0)