Release and Publish #30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release and Publish | |
| on: | |
| workflow_dispatch: {} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| BINARY_NAME: YouTubeTLDR | |
| jobs: | |
| build: | |
| name: Build on ${{ matrix.os }} for ${{ matrix.target || 'default' }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ ubuntu-latest, macos-15, windows-latest, ubuntu-24.04-arm, windows-11-arm ] | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v5 | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: nightly | |
| override: true | |
| cache: true | |
| components: rust-src | |
| - name: Get Target Triple | |
| id: get_target | |
| run: | | |
| if [[ -n "${{ matrix.target }}" ]]; then | |
| TARGET_TRIPLE="${{ matrix.target }}" | |
| else | |
| TARGET_TRIPLE=$(rustc -vV | sed -n 's/host: //p') | |
| fi | |
| echo "TARGET_TRIPLE=${TARGET_TRIPLE}" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Create Platform Identifier | |
| id: platform | |
| shell: bash | |
| run: | | |
| ARCH=$(echo "${{ env.TARGET_TRIPLE }}" | cut -d'-' -f1) | |
| OS_NAME=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]') | |
| PLATFORM_ID="${ARCH}-${OS_NAME}" | |
| echo "PLATFORM_ID=${PLATFORM_ID}" >> $GITHUB_ENV | |
| echo "Binary will be named for platform: ${PLATFORM_ID}" | |
| - name: Build | |
| run: cargo build -Z build-std=std,panic_abort -Z build-std-features= --release --target ${{ env.TARGET_TRIPLE }} | |
| - name: Prepare Release Assets | |
| shell: bash | |
| run: | | |
| mkdir release_assets | |
| EXE_SUFFIX="" | |
| if [[ "${{ runner.os }}" == "Windows" ]]; then | |
| EXE_SUFFIX=".exe" | |
| fi | |
| BINARY_FILENAME="${{ env.BINARY_NAME }}-${{ env.PLATFORM_ID }}${EXE_SUFFIX}" | |
| BIN_SRC_PATH="target/${{ env.TARGET_TRIPLE }}/release/${{ env.BINARY_NAME }}${EXE_SUFFIX}" | |
| BIN_DEST_PATH="release_assets/${BINARY_FILENAME}" | |
| echo "Copying binary from ${BIN_SRC_PATH} to ${BIN_DEST_PATH}" | |
| cp "${BIN_SRC_PATH}" "${BIN_DEST_PATH}" | |
| echo "Listing prepared release assets:" | |
| ls -R release_assets | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: app-binaries-${{ env.PLATFORM_ID }} | |
| path: release_assets/ | |
| release: | |
| name: Create GitHub Release | |
| runs-on: ubuntu-latest | |
| needs: build | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download all build artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| path: release-assets/ | |
| - name: List downloaded files | |
| run: ls -R release-assets/ | |
| - name: Create Release and Upload Assets | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: ${{ startsWith(github.ref, 'refs/tags/') && format('Release {0}', github.ref_name) || format('Build from {0}', github.ref_name) }} | |
| draft: true | |
| generate_release_notes: true | |
| files: release-assets/**/* |