|
5 | 5 | tags: |
6 | 6 | - "v*.*.*" |
7 | 7 | workflow_dispatch: |
8 | | - |
9 | | -env: |
10 | | - # The smbcloud-cli binary name |
11 | | - PROJECT_NAME: smb |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: "Release tag (e.g. v0.3.35)" |
| 11 | + required: true |
12 | 12 |
|
13 | 13 | permissions: |
14 | 14 | contents: write |
15 | 15 |
|
| 16 | +env: |
| 17 | + PROJECT_NAME: smb |
| 18 | + CARGO_TERM_COLOR: always |
| 19 | + |
16 | 20 | jobs: |
17 | 21 | build: |
| 22 | + name: Build binary (${{ matrix.name }}) |
18 | 23 | runs-on: ${{ matrix.runner }} |
19 | 24 |
|
20 | 25 | strategy: |
| 26 | + fail-fast: false |
21 | 27 | matrix: |
22 | 28 | include: |
23 | 29 | - name: linux-amd64 |
24 | 30 | runner: ubuntu-latest |
25 | 31 | target: x86_64-unknown-linux-gnu |
| 32 | + - name: linux-arm64 |
| 33 | + runner: ubuntu-24.04-arm |
| 34 | + target: aarch64-unknown-linux-gnu |
26 | 35 | - name: win-amd64 |
27 | 36 | runner: windows-latest |
28 | 37 | target: x86_64-pc-windows-msvc |
29 | | - #- name: macos-amd64 |
30 | | - # runner: macos-latest |
31 | | - # target: x86_64-apple-darwin |
| 38 | + - name: win-arm64 |
| 39 | + runner: windows-latest |
| 40 | + target: aarch64-pc-windows-msvc |
| 41 | + - name: macos-amd64 |
| 42 | + runner: macos-15-intel |
| 43 | + target: x86_64-apple-darwin |
32 | 44 | - name: macos-arm64 |
33 | 45 | runner: macos-latest |
34 | 46 | target: aarch64-apple-darwin |
35 | 47 |
|
36 | 48 | steps: |
37 | 49 | - name: Checkout |
38 | | - uses: actions/checkout@v3 |
39 | | - |
40 | | - - name: Install Rust |
41 | | - uses: dtolnay/rust-toolchain@stable |
| 50 | + uses: actions/checkout@v6 |
42 | 51 | with: |
43 | | - toolchain: 1.92 |
44 | | - targets: "${{ matrix.target }}" |
| 52 | + ref: ${{ github.event.inputs.tag || github.ref }} |
45 | 53 |
|
46 | | - #- name: Install OpenSSL |
47 | | - # if: matrix.name == 'macos-amd64' |
48 | | - # run: brew install openssl@3 |
| 54 | + - name: Set the release version |
| 55 | + shell: bash |
| 56 | + run: | |
| 57 | + if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then |
| 58 | + release_version="${GITHUB_REF_NAME#v}" |
| 59 | + else |
| 60 | + release_version="${{ github.event.inputs.tag }}" |
| 61 | + release_version="${release_version#v}" |
| 62 | + fi |
| 63 | +
|
| 64 | + echo "RELEASE_VERSION=${release_version}" >> "$GITHUB_ENV" |
| 65 | +
|
| 66 | + - name: Read Rust toolchain |
| 67 | + shell: bash |
| 68 | + run: | |
| 69 | + rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)" |
| 70 | + if [ -z "$rust_toolchain" ]; then |
| 71 | + echo "Failed to read Rust toolchain from rust-toolchain.toml" >&2 |
| 72 | + exit 1 |
| 73 | + fi |
49 | 74 |
|
50 | | - - name: Setup Cache |
| 75 | + echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV" |
| 76 | +
|
| 77 | + - name: Install toolkit |
| 78 | + uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 |
| 79 | + with: |
| 80 | + toolchain: ${{ env.RUST_TOOLCHAIN }} |
| 81 | + targets: ${{ matrix.target }} |
| 82 | + |
| 83 | + - name: Setup Rust cache |
51 | 84 | uses: Swatinem/rust-cache@v2 |
| 85 | + with: |
| 86 | + key: github-${{ matrix.target }} |
52 | 87 |
|
53 | 88 | - name: Create .env file |
54 | 89 | run: | |
55 | 90 | touch .env |
56 | 91 | echo CLI_CLIENT_SECRET=${{ secrets.CLI_CLIENT_SECRET }} >> .env |
57 | 92 | cat .env |
58 | 93 |
|
59 | | - - name: Build Binary |
60 | | - run: cargo build --verbose --locked --release --target ${{ matrix.target }} |
| 94 | + - name: Build binary |
| 95 | + shell: bash |
| 96 | + run: cargo build --locked --release --target ${{ matrix.target }} --package smbcloud-cli |
61 | 97 |
|
62 | | - - name: Release Binary |
| 98 | + - name: Package binary |
63 | 99 | shell: bash |
64 | 100 | run: | |
65 | 101 | BIN_SUFFIX="" |
66 | 102 | if [[ "${{ matrix.runner }}" == "windows-latest" ]]; then |
67 | 103 | BIN_SUFFIX=".exe" |
68 | 104 | fi |
69 | 105 |
|
70 | | - # The built binary output location |
71 | 106 | BIN_OUTPUT="target/${{ matrix.target }}/release/${PROJECT_NAME}${BIN_SUFFIX}" |
72 | | -
|
73 | | - # Define a better name for the final binary |
74 | 107 | BIN_RELEASE="${PROJECT_NAME}-${{ matrix.name }}${BIN_SUFFIX}" |
75 | | - BIN_RELEASE_VERSIONED="${PROJECT_NAME}-${{ github.ref_name }}-${{ matrix.name }}${BIN_SUFFIX}" |
76 | 108 |
|
77 | | - # Move the built binary where you want it |
78 | | - DEST_DIR="./release" |
| 109 | + mkdir -p ./release |
| 110 | + mv "${BIN_OUTPUT}" "./release/${BIN_RELEASE}" |
| 111 | +
|
| 112 | + - name: Upload artifact |
| 113 | + uses: actions/upload-artifact@v7 |
| 114 | + with: |
| 115 | + name: binary-${{ matrix.name }} |
| 116 | + path: release/* |
79 | 117 |
|
80 | | - mkdir -p "${DEST_DIR}" |
81 | | - mv "${BIN_OUTPUT}" "${DEST_DIR}/${BIN_RELEASE}" |
| 118 | + release: |
| 119 | + name: Create GitHub Release |
| 120 | + needs: build |
| 121 | + runs-on: ubuntu-latest |
| 122 | + if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' |
| 123 | + |
| 124 | + steps: |
| 125 | + - name: Resolve tag |
| 126 | + id: tag |
| 127 | + shell: bash |
| 128 | + run: | |
| 129 | + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then |
| 130 | + echo "tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT" |
| 131 | + else |
| 132 | + echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" |
| 133 | + fi |
| 134 | +
|
| 135 | + - name: Download all artifacts |
| 136 | + uses: actions/download-artifact@v7 |
| 137 | + with: |
| 138 | + pattern: "binary-*" |
| 139 | + path: release |
| 140 | + merge-multiple: true |
82 | 141 |
|
83 | 142 | - name: Release |
84 | 143 | uses: softprops/action-gh-release@v2 |
85 | | - if: github.ref_type == 'tag' |
86 | 144 | with: |
| 145 | + tag_name: ${{ steps.tag.outputs.tag }} |
87 | 146 | files: release/* |
0 commit comments