|
| 1 | +name: "Release Libraries" |
| 2 | + |
| 3 | +env: |
| 4 | + RUST_VERSION: "1.73.0" |
| 5 | + CROSS_VERSION: "0.2.4" |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + tag: |
| 11 | + description: 'Create release with tag' |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-swift-package: |
| 17 | + name: Build Swift Package |
| 18 | + runs-on: macos-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v3 |
| 23 | + |
| 24 | + - name: Cache cargo resources |
| 25 | + uses: Swatinem/rust-cache@v2 |
| 26 | + with: |
| 27 | + shared-key: deps |
| 28 | + save-if: false |
| 29 | + |
| 30 | + - name: Build library for macOS |
| 31 | + if: "runner.os == 'macOS'" |
| 32 | + run: | |
| 33 | + cd uniffi |
| 34 | + echo "TAG: ${{github.event.inputs.tag}}" |
| 35 | + ./build-release-apple-universal.sh |
| 36 | + cd .. |
| 37 | + checksum=$(swift package compute-checksum 'uniffi/output-frameworks/anoncreds-swift/libanoncreds.xcframework.zip') |
| 38 | + echo "CHECKSUM: $checksum" |
| 39 | + rm -f Package.swift |
| 40 | + ./.scripts/updatePackage.swift ${{github.event.inputs.tag}} $checksum 'uniffi/output-frameworks/anoncreds-swift/libanoncreds.xcframework.zip' 'Package.swift' |
| 41 | + |
| 42 | + - name: Commit package |
| 43 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 44 | + with: |
| 45 | + commit_message: "chore: prepare release ${{github.event.inputs.tag}}" |
| 46 | + tagging_message: ${{github.event.inputs.tag}} |
| 47 | + |
| 48 | + - name: Upload library artifacts |
| 49 | + uses: actions/upload-artifact@v3 |
| 50 | + with: |
| 51 | + name: libanoncreds.xcframework.zip |
| 52 | + path: 'uniffi/output-frameworks/anoncreds-swift/libanoncreds.xcframework.zip' |
| 53 | + |
| 54 | + - name: Create library artifacts directory |
| 55 | + run: | |
| 56 | + mkdir release-artifacts |
| 57 | + cp 'uniffi/output-frameworks/anoncreds-swift/libanoncreds.xcframework.zip' release-artifacts/ |
| 58 | +
|
| 59 | + - name: Add swift package artifacts to release |
| 60 | + uses: svenstaro/upload-release-action@v2 |
| 61 | + with: |
| 62 | + file: uniffi/output-frameworks/anoncreds-swift/libanoncreds.xcframework.zip |
| 63 | + asset_name: "libanoncreds.xcframework.zip" |
| 64 | + |
| 65 | + build-release: |
| 66 | + needs: build-swift-package |
| 67 | + name: Build Library |
| 68 | + |
| 69 | + strategy: |
| 70 | + matrix: |
| 71 | + include: |
| 72 | + - architecture: linux-aarch64 |
| 73 | + os: ubuntu-20.04 |
| 74 | + target: aarch64-unknown-linux-gnu |
| 75 | + lib: libanoncreds_uniffi.so |
| 76 | + libPath: uniffi/target/aarch64-unknown-linux-gnu/release/libanoncreds_uniffi.so |
| 77 | + use_cross: true |
| 78 | + - architecture: linux-x86_64 |
| 79 | + os: ubuntu-20.04 |
| 80 | + target: x86_64-unknown-linux-gnu |
| 81 | + lib: libanoncreds_uniffi.so |
| 82 | + libPath: uniffi/target/x86_64-unknown-linux-gnu/release/libanoncreds_uniffi.so |
| 83 | + use_cross: true |
| 84 | + - architecture: darwin-x86_64 |
| 85 | + os: macos-latest |
| 86 | + target: x86_64-apple-darwin |
| 87 | + lib: libanoncreds_uniffi.dylib |
| 88 | + libPath: uniffi/target/x86_64-apple-darwin/release/libanoncreds_uniffi.dylib |
| 89 | + - architecture: darwin-aarch64 |
| 90 | + os: macos-latest |
| 91 | + target: aarch64-apple-darwin |
| 92 | + lib: libanoncreds_uniffi.dylib |
| 93 | + libPath: uniffi/target/aarch64-apple-darwin/release/libanoncreds_uniffi.dylib |
| 94 | + |
| 95 | + runs-on: ${{ matrix.os }} |
| 96 | + |
| 97 | + steps: |
| 98 | + - name: Checkout |
| 99 | + uses: actions/checkout@v3 |
| 100 | + |
| 101 | + - name: Install Rust toolchain |
| 102 | + if: "matrix.target != 'swift-package-universal'" |
| 103 | + uses: dtolnay/rust-toolchain@stable |
| 104 | + with: |
| 105 | + toolchain: ${{ env.RUST_VERSION }} |
| 106 | + targets: ${{ matrix.target }} |
| 107 | + |
| 108 | + - name: Cache cargo resources |
| 109 | + uses: Swatinem/rust-cache@v2 |
| 110 | + with: |
| 111 | + shared-key: deps |
| 112 | + save-if: false |
| 113 | + |
| 114 | + - name: Build library for Linux |
| 115 | + if: "runner.os == 'Linux'" |
| 116 | + run: | |
| 117 | + cd uniffi |
| 118 | + if [ -n "${{ matrix.use_cross }}" ]; then |
| 119 | + cargo install --git https://github.com/cross-rs/cross --tag v${{ env.CROSS_VERSION }} cross |
| 120 | + cross build --release --target ${{matrix.target}} |
| 121 | + else |
| 122 | + cargo build --release --target ${{matrix.target}} |
| 123 | + fi |
| 124 | +
|
| 125 | + - name: Build library for macOS |
| 126 | + if: "runner.os == 'macOS'" |
| 127 | + run: | |
| 128 | + cd uniffi |
| 129 | + if [ "${{ matrix.architecture }}" == "swift-package-universal" ]; then |
| 130 | + echo "TAG: ${{github.event.inputs.tag}}" |
| 131 | + ./build-release-apple-universal.sh |
| 132 | + cd .. |
| 133 | + checksum=$(swift package compute-checksum '${{matrix.libPath}}') |
| 134 | + echo "CHECKSUM: $checksum" |
| 135 | + rm Package.swift |
| 136 | + ./scripts/updatePackage.swift ${{github.event.inputs.tag}} $checksum '${{ matrix.libPath }}' 'Package.swift' |
| 137 | + else |
| 138 | + cargo build --release --target ${{matrix.target}} |
| 139 | + fi |
| 140 | + |
| 141 | + - name: Commit package |
| 142 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 143 | + if: | |
| 144 | + matrix.architecture != 'swift-package-universal' |
| 145 | + with: |
| 146 | + commit_message: "chore: prepare release ${{github.event.inputs.tag}}" |
| 147 | + tagging_message: ${{github.event.inputs.tag}} |
| 148 | + |
| 149 | + - name: Upload library artifacts |
| 150 | + uses: actions/upload-artifact@v3 |
| 151 | + with: |
| 152 | + name: ${{ matrix.lib }} |
| 153 | + path: ${{ matrix.libPath }} |
| 154 | + |
| 155 | + - name: Create library artifacts directory |
| 156 | + run: | |
| 157 | + mkdir release-artifacts |
| 158 | + cp ${{ matrix.libPath }} release-artifacts/ |
| 159 | +
|
| 160 | + - name: Release artifacts |
| 161 | + |
| 162 | + if: | |
| 163 | + matrix.architecture != 'swift-package-universal' |
| 164 | + with: |
| 165 | + command: c |
| 166 | + cwd: release-artifacts |
| 167 | + files: . |
| 168 | + outPath: "library-${{ matrix.architecture }}.tar.gz" |
| 169 | + |
| 170 | + - name: Add library artifacts to release |
| 171 | + if: | |
| 172 | + matrix.architecture != 'swift-package-universal' |
| 173 | + uses: svenstaro/upload-release-action@v2 |
| 174 | + with: |
| 175 | + file: library-${{ matrix.architecture }}.tar.gz |
| 176 | + asset_name: "library-${{ matrix.architecture }}-${{ github.sha }}.tar.gz" |
| 177 | + |
| 178 | + - name: Add swift package artifacts to release |
| 179 | + if: | |
| 180 | + matrix.architecture == 'swift-package-universal' |
| 181 | + uses: svenstaro/upload-release-action@v2 |
| 182 | + with: |
| 183 | + file: ${{ matrix.libPath }} |
| 184 | + asset_name: "${{ matrix.lib }}" |
0 commit comments