-
Notifications
You must be signed in to change notification settings - Fork 6
104 lines (104 loc) · 3.61 KB
/
release.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Publish new release
env:
RUST_VERSION: nightly
RUST_TARGETS: aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios
ZIP_FILE_NAME: Tesseract-Core.bin.zip
CI_COMMIT_AUTHOR: Release Action
CI_COMMIT_MESSAGE: Package.swift Rust binary update
on:
workflow_dispatch:
inputs:
version:
description: 'Release Version'
required: true
type: string
name:
description: 'Release Name'
required: true
type: string
notes:
description: 'Release Notes'
required: true
type: string
prerelease:
description: 'Prerelease'
type: boolean
required: false
draft:
description: 'Draft release'
type: boolean
required: false
jobs:
build-core-and-deploy:
name: Build Core
runs-on: macOS-13
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_14.3.1.app
- name: Install Rust
uses: brndnmtthws/rust-action-rustup@v1
with:
toolchain: ${{env.RUST_VERSION}}
targets: ${{env.RUST_TARGETS}}
profile: minimal
- name: Install cbindgen
run: cargo install --force cbindgen
- name: Build Core Zip
id: build-core-zip
env:
ZIP_NAME: ${{env.ZIP_FILE_NAME}}
run: |
Rust/generate_binary_zip.sh "${ZIP_NAME}"
SHA=$(swift package compute-checksum "${ZIP_NAME}")
echo "ZIP_SHA=${SHA}" >> "$GITHUB_OUTPUT"
echo "ZIP_NAME=${ZIP_NAME}" >> "$GITHUB_OUTPUT"
- name: Update Package.swift
env:
ZIP_NAME: ${{ steps.build-core-zip.outputs.ZIP_NAME }}
ZIP_SHA: ${{ steps.build-core-zip.outputs.ZIP_SHA }}
VERSION: ${{ inputs.version }}
run: |
ZIP_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/$VERSION/$ZIP_NAME"
sed -i '' "s|let[[:blank:]]*binaryUrl.*|let binaryUrl = \"${ZIP_URL}\"|g" Package.swift
sed -i '' "s|let[[:blank:]]*binaryChecksum.*|let binaryChecksum = \"${ZIP_SHA}\"|g" Package.swift
sed -i '' "s|let[[:blank:]]useLocalBinary[[:blank:]]=[[:blank:]]true|let useLocalBinary = false|g" Package.swift
- name: Commit and create tag
env:
VERSION: ${{ inputs.version }}
RELEASE: ${{ inputs.name }}
run: |
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "[email protected]"
git add Package.swift
git add --all Sources/CTesseractShared/
git commit -m "${{ env.CI_COMMIT_MESSAGE }} for ${VERSION}"
git push origin
git tag -a "${VERSION}" -m "${RELEASE}"
git push origin "${VERSION}"
- name: Create release
uses: softprops/action-gh-release@v1
with:
tag_name: refs/tags/${{ inputs.version }}
name: ${{ inputs.name }}
body: ${{ inputs.notes }}
prerelease: ${{ inputs.prerelease }}
draft: ${{ inputs.draft }}
files: ${{ steps.build-core-zip.outputs.ZIP_NAME }}
publish-pod:
name: Publish to Cocoa Pods
needs: build-core-and-deploy
uses: "./.github/workflows/publish_pod.yml"
with:
version: ${{ inputs.version }}
secrets:
trunk-token: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
publish-crate:
name: Publish to Crates
needs: build-core-and-deploy
uses: "./.github/workflows/publish_crate.yml"
with:
version: ${{ inputs.version }}
secrets:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}