Skip to content
Merged
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
72 changes: 53 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@ name: Release

on:
workflow_dispatch:
release:
types: [published]
inputs:
version:
description: "Version to release (e.g. 1.2.3)"
required: true
type: string
dry_run:
description: "Dry run"
required: true
type: boolean

permissions:
contents: write
id-token: write
attestations: write
artifact-metadata: write

jobs:
build:
Expand All @@ -14,23 +27,26 @@ jobs:
destination:
- { name: "ubuntu-aarch64", os: ubuntu-22.04-arm }
- { name: "ubuntu-x86_64", os: ubuntu-22.04 }
- { name: "macos-universal", os: macos-15 }
- { name: "macos-universal", os: macos-26 }
steps:
- if: startsWith(matrix.destination.name, 'ubuntu')
uses: vapor/swiftly-action@v0.2
with:
toolchain: "6.2"
- if: startsWith(matrix.destination.name, 'macos')
run: sudo xcode-select -s /Applications/Xcode_26.1.app
run: sudo xcode-select -s /Applications/Xcode_26.3.app

- uses: actions/checkout@v6
- name: Update Version.swift
run: echo "let version = \"${{ inputs.version }}\"" > Sources/Mockolo/Version.swift
- name: Create the binary
run: ./install-script.sh -s . -t mockolo -d . -o mockolo.${{ matrix.destination.name }}.tar.gz
- name: Upload the binary
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@v7
with:
name: mockolo.${{ matrix.destination.name }}.tar.gz
path: mockolo.${{ matrix.destination.name }}.tar.gz
archive: false

check-portability:
needs: build
Expand All @@ -48,9 +64,10 @@ jobs:
- { name: "macos-universal", os: macos-15 }
- { name: "macos-universal", os: macos-14 }
steps:
- uses: actions/download-artifact@v7
- uses: actions/download-artifact@v8
with:
name: mockolo.${{ matrix.destination.name }}.tar.gz
skip-decompress: true
- name: Unpack the binary
run: tar -xvf mockolo.${{ matrix.destination.name }}.tar.gz
- name: Run the binary
Expand All @@ -64,48 +81,65 @@ jobs:
steps:
- uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v7
uses: actions/download-artifact@v8
with:
merge-multiple: true
skip-decompress: true

- run: bundle/make_artifactbundle.sh ${{ github.event.release.tag_name || github.ref_name }}
- run: bundle/make_artifactbundle.sh "${{ inputs.version }}"

- name: Upload artifact bundle
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@v7
with:
name: mockolo.artifactbundle.zip
path: mockolo.artifactbundle.zip
# GitHub re-compresses the zip file, resulting in a broken zip file
archive: false

- name: Compute checksum
id: checksum
run: echo "checksum=$(swift package compute-checksum mockolo.artifactbundle.zip)" >> "$GITHUB_OUTPUT"
run: echo "checksum=$(swift package compute-checksum mockolo.artifactbundle.zip)" | tee -a "$GITHUB_OUTPUT"

deploy-binary:
if: ${{ github.event_name == 'release' }}
publish:
if: ${{ !inputs.dry_run }}
needs: [check-portability, make-artifact-bundle]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v7
- uses: actions/download-artifact@v8
with:
merge-multiple: true
- name: Deploy the binary
skip-decompress: true

- name: Generate signed attestations
uses: actions/attest@v4
with:
subject-path: |
mockolo.ubuntu-x86_64.tar.gz
mockolo.ubuntu-aarch64.tar.gz
mockolo.macos-universal.tar.gz
mockolo.artifactbundle.zip

- name: Publish to GitHub Releases
uses: softprops/action-gh-release@v2
with:
name: ${{ inputs.version }}
tag_name: ${{ inputs.version }}
target_commitish: ${{ github.sha }}
body: |
----

## For Build Tools Plugin (artifactbundle)

```swift
.binaryTarget(
name: "mockolo",
url: "https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/mockolo.artifactbundle.zip",
url: "https://github.com/${{ github.repository }}/releases/download/${{ inputs.version }}/mockolo.artifactbundle.zip",
checksum: "${{ needs.make-artifact-bundle.outputs.checksum }}"
),
```

append_body: true
generate_release_notes: true
files: |
mockolo.ubuntu-x86_64.tar.gz
mockolo.ubuntu-aarch64.tar.gz
mockolo.macos-universal.tar.gz
mockolo.artifactbundle.zip
fail_on_unmatched_files: true
draft: true
2 changes: 1 addition & 1 deletion Sources/Mockolo/Mockolo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct Mockolo {
static func main() {
let inputs = Array(CommandLine.arguments.dropFirst())
if let arg = inputs.first, (arg == "--version" || arg == "-v") {
print(Version.current.value)
print(version)
return
}

Expand Down
1 change: 1 addition & 0 deletions Sources/Mockolo/Version.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let version = "development"
7 changes: 0 additions & 7 deletions Sources/MockoloFramework/Version.swift

This file was deleted.