Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions workflows to attach release assets. Fix #427 #616

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/add-release-asset-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and attach on releases – MacOS

on:
release:
types: [published]

jobs:
release:
runs-on: macos-12

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 }}.macos.zip
cd .build/release/
echo "xattr -c swift-format" > disable-codesigning.sh
zip $FILENAME swift-format disable-codesigning.sh
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 }}
50 changes: 50 additions & 0 deletions .github/workflows/add-release-asset-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 }}