1 name: GitHub Release
2
3 on:
4 push:
5 tags:
6 - "v*.*.*"
7 workflow_dispatch:
8
9 env:
10 # The smbcloud-cli binary name
11 PROJECT_NAME: smb
12
13 permissions:
14 contents: write
15
16 jobs:
17 build:
18 runs-on: ${{ matrix.runner }}
19
20 strategy:
21 matrix:
22 include:
23 - name: linux-amd64
24 runner: ubuntu-latest
25 target: x86_64-unknown-linux-gnu
26 - name: win-amd64
27 runner: windows-latest
28 target: x86_64-pc-windows-msvc
29 #- name: macos-amd64
30 # runner: macos-latest
31 # target: x86_64-apple-darwin
32 - name: macos-arm64
33 runner: macos-latest
34 target: aarch64-apple-darwin
35
36 steps:
37 - name: Checkout
38 uses: actions/checkout@v3
39
40 - name: Install Rust
41 uses: dtolnay/rust-toolchain@stable
42 with:
43 toolchain: 1.92
44 targets: "${{ matrix.target }}"
45
46 #- name: Install OpenSSL
47 # if: matrix.name == 'macos-amd64'
48 # run: brew install openssl@3
49
50 - name: Setup Cache
51 uses: Swatinem/rust-cache@v2
52
53 - name: Create .env file
54 run: |
55 touch .env
56 echo CLI_CLIENT_SECRET=${{ secrets.CLI_CLIENT_SECRET }} >> .env
57 cat .env
58
59 - name: Build Binary
60 run: cargo build --verbose --locked --release --target ${{ matrix.target }}
61
62 - name: Release Binary
63 shell: bash
64 run: |
65 BIN_SUFFIX=""
66 if [[ "${{ matrix.runner }}" == "windows-latest" ]]; then
67 BIN_SUFFIX=".exe"
68 fi
69
70 # The built binary output location
71 BIN_OUTPUT="target/${{ matrix.target }}/release/${PROJECT_NAME}${BIN_SUFFIX}"
72
73 # Define a better name for the final binary
74 BIN_RELEASE="${PROJECT_NAME}-${{ matrix.name }}${BIN_SUFFIX}"
75 BIN_RELEASE_VERSIONED="${PROJECT_NAME}-${{ github.ref_name }}-${{ matrix.name }}${BIN_SUFFIX}"
76
77 # Move the built binary where you want it
78 DEST_DIR="./release"
79
80 mkdir -p "${DEST_DIR}"
81 mv "${BIN_OUTPUT}" "${DEST_DIR}/${BIN_RELEASE}"
82
83 - name: Release
84 uses: softprops/action-gh-release@v2
85 if: github.ref_type == 'tag'
86 with:
87 files: release/*