diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1596b42c..ca86d85c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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: @@ -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 @@ -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 @@ -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 diff --git a/Sources/Mockolo/Mockolo.swift b/Sources/Mockolo/Mockolo.swift index a81adaf4..bddf9e90 100644 --- a/Sources/Mockolo/Mockolo.swift +++ b/Sources/Mockolo/Mockolo.swift @@ -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 } diff --git a/Sources/Mockolo/Version.swift b/Sources/Mockolo/Version.swift new file mode 100644 index 00000000..ff448151 --- /dev/null +++ b/Sources/Mockolo/Version.swift @@ -0,0 +1 @@ +let version = "development" diff --git a/Sources/MockoloFramework/Version.swift b/Sources/MockoloFramework/Version.swift deleted file mode 100644 index 41196a13..00000000 --- a/Sources/MockoloFramework/Version.swift +++ /dev/null @@ -1,7 +0,0 @@ -public struct Version { - /// The string value for this version. - public let value: String - - /// The current Mockolo version. - public static let current = Version(value: "2.6.0") -}