|
| 1 | +name: Build and Upload .NET binary |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build-and-pack: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + os: [linux-x64, linux-arm64, win-x64, osx-x64, osx-arm64] |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v6 |
| 17 | + |
| 18 | + - name: Extract version (without v) |
| 19 | + id: version |
| 20 | + run: | |
| 21 | + if [ "${{ github.event_name }}" = "release" ]; then |
| 22 | + # Extract version from release tag (remove any 'v' prefix) |
| 23 | + VERSION="${{ github.event.release.tag_name }}" |
| 24 | + VERSION=${VERSION#v} # Remove 'v' prefix if present |
| 25 | + else |
| 26 | + VERSION="${{ github.event.inputs.version }}" |
| 27 | + VERSION=${VERSION#v} # Remove 'v' prefix if present |
| 28 | + fi |
| 29 | +
|
| 30 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 31 | + echo "Syncing version: $VERSION" |
| 32 | +
|
| 33 | + - name: Build & Publish |
| 34 | + run: | |
| 35 | + dotnet publish ./src/BuslyCLI.Console/BuslyCLI.Console.csproj \ |
| 36 | + --configuration Release \ |
| 37 | + --runtime ${{ matrix.os }} \ |
| 38 | + --self-contained true \ |
| 39 | + --output ./artifacts/binaries/${{ matrix.os }} \ |
| 40 | + /p:PublishSingleFile=true |
| 41 | +
|
| 42 | + - name: Create Archive |
| 43 | + run: | |
| 44 | + TARGET_DIR="./artifacts/binaries/${{ matrix.os }}" |
| 45 | + OUTPUT_BASE="./artifacts/github-release-archives/busly-cli-${{ github.event.release.tag_name }}-${{ matrix.os }}" |
| 46 | +
|
| 47 | + if [[ "${{ matrix.os }}" == "win-x64" ]]; then |
| 48 | + zip -r "${OUTPUT_BASE}.zip" . -C "$TARGET_DIR" |
| 49 | + else |
| 50 | + tar -czf "${OUTPUT_BASE}.tar.gz" -C "$TARGET_DIR" . |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Upload Release Asset |
| 54 | + uses: actions/upload-release-asset@v1 |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + with: |
| 58 | + upload_url: ${{ github.event.release.upload_url }} |
| 59 | + asset_path: ./artifacts/github-release-archives/busly-cli-${{ github.event.release.tag_name }}-${{ matrix.os }}.${{ matrix.os == 'win-x64' && 'zip' || 'tar.gz' }} |
| 60 | + asset_name: busyly-cli${{ github.event.release.tag_name }}-${{ matrix.os }}.${{ matrix.os == 'win-x64' && 'zip' || 'tar.gz' }} |
| 61 | + asset_content_type: ${{ matrix.os == 'win-x64' && 'application/zip' || 'application/gzip' }} |
0 commit comments