Update build-release.yml #9
Workflow file for this run
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: Build and Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| jobs: | |
| build-and-release: | |
| if: "!contains(github.event.head_commit.message, '[skip ci]')" | |
| strategy: | |
| matrix: | |
| include: | |
| # Linux | |
| - os: ubuntu-latest | |
| arch: amd64 | |
| platform: linux | |
| artifact_name: todo-app | |
| - os: ubuntu-latest | |
| arch: arm64 | |
| platform: linux | |
| artifact_name: todo-app | |
| # macOS | |
| - os: macos-latest | |
| arch: amd64 | |
| platform: macos | |
| artifact_name: todo-app | |
| - os: macos-latest | |
| arch: arm64 | |
| platform: macos | |
| artifact_name: todo-app | |
| # Windows | |
| - os: windows-latest | |
| arch: amd64 | |
| platform: windows | |
| artifact_name: todo-app.exe | |
| - os: windows-latest | |
| arch: arm64 | |
| platform: windows | |
| artifact_name: todo-app.exe | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install ARM64 Cross-Compiler (Linux) | |
| if: matrix.platform == 'linux' && matrix.arch == 'arm64' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
| - uses: jwlawson/actions-setup-cmake@v2 | |
| with: | |
| cmake-version: '3.25.x' | |
| - name: Configure CMake | |
| run: | | |
| if [ "${{ matrix.platform }}" = "linux" ] && [ "${{ matrix.arch }}" = "arm64" ]; then | |
| cmake -B build -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \ | |
| -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ | |
| elif [ "${{ matrix.platform }}" = "macos" ] && [ "${{ matrix.arch }}" = "arm64" ]; then | |
| cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 | |
| elif [ "${{ matrix.platform }}" = "windows" ] && [ "${{ matrix.arch }}" = "arm64" ]; then | |
| cmake -B build -DCMAKE_BUILD_TYPE=Release -A ARM64 | |
| else | |
| cmake -B build -DCMAKE_BUILD_TYPE=Release | |
| fi | |
| shell: bash | |
| - name: Build | |
| run: cmake --build build --config Release | |
| - name: Prepare Artifacts and Checksum | |
| shell: bash | |
| run: | | |
| mkdir -p out | |
| VERSION=${GITHUB_REF_NAME} | |
| ASSET_NAME="todo-app-${VERSION}-${{ matrix.platform }}-${{ matrix.arch }}" | |
| if [ "${{ matrix.platform }}" = "windows" ]; then | |
| FINAL_NAME="${ASSET_NAME}.exe" | |
| # Handle Windows build path differences | |
| if [ -f "build/Release/${{ matrix.artifact_name }}" ]; then | |
| cp "build/Release/${{ matrix.artifact_name }}" "out/${FINAL_NAME}" | |
| else | |
| cp "build/${{ matrix.artifact_name }}" "out/${FINAL_NAME}" | |
| fi | |
| else | |
| FINAL_NAME="${ASSET_NAME}" | |
| cp build/${{ matrix.artifact_name }} out/${FINAL_NAME} | |
| chmod +x out/${FINAL_NAME} | |
| fi | |
| # Generate Checksum | |
| cd out | |
| if command -v sha256sum >/dev/null 2>&1; then | |
| sha256sum "${FINAL_NAME}" > "${FINAL_NAME}.sha256" | |
| else | |
| shasum -a 256 "${FINAL_NAME}" > "${FINAL_NAME}.sha256" | |
| fi | |
| echo "artifact_path=out/${FINAL_NAME}" >> $GITHUB_ENV | |
| echo "checksum_path=out/${FINAL_NAME}.sha256" >> $GITHUB_ENV | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.platform }}-${{ matrix.arch }} | |
| path: | | |
| ${{ env.artifact_path }} | |
| ${{ env.checksum_path }} | |
| release: | |
| needs: build-and-release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: all-artifacts | |
| merge-multiple: true | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: "CLI Todo App ${{ github.ref_name }}" | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| files: all-artifacts/* |