-
Notifications
You must be signed in to change notification settings - Fork 243
50 lines (40 loc) · 1.57 KB
/
add-release-asset-ubuntu.yml
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
name: Build and attach on releases - Ubuntu
on:
release:
types: [published]
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name }}
# @see https://github.com/apple/swift-format/commit/705038361379825ef201d96f2709587b08212f5a
# NB: sed syntax differs between MacOS and Ubuntu
- name: Edit `VersionOptions.swift` to update the version number
env:
CURRENT_RELEASE: ${{ github.event.release.tag_name }}
run: |
find . -name 'VersionOptions.swift' -exec sed -i 's/print(".*")/print("'$CURRENT_RELEASE'")/g' {} +
cat Sources/swift-format/VersionOptions.swift
# Should output executable to `.build/release/swift-format`
- name: Build
run: swift build --disable-sandbox -c release
# Smoke test
- name: Test the executable works
run: .build/release/swift-format --version
# Zip the executable so it can be given a descriptive name to distinguish the MacOS and Ubuntu builds
- name: Create archive
id: create-archive
run: |
FILENAME=swift-format.${{ github.event.release.name }}.ubuntu.zip
cd .build/release/
zip $FILENAME swift-format
echo "ARCHIVE_ABSOLUTE_FILEPATH=$(pwd)/$FILENAME" >> $GITHUB_OUTPUT;
- name: Attach asset
uses: softprops/action-gh-release@v1
with:
files: ${{ steps.create-archive.outputs.ARCHIVE_ABSOLUTE_FILEPATH }}