Update README.md #5
This file contains 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: C/C++ Cross-Platform CI | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
permissions: | |
contents: write | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-latest | |
arch: x86 | |
install_deps: "sudo apt-get update && sudo apt-get install -y gcc-multilib g++-multilib" | |
build_command: "gcc -Ofast -m32 prime_finder.c -o prime_finder_x86 -lm" | |
- os: ubuntu-latest | |
arch: x64 | |
install_deps: "sudo apt-get update && sudo apt-get install -y build-essential" | |
build_command: "gcc -Ofast prime_finder.c -o prime_finder_x64 -lm" | |
- os: windows-latest | |
arch: x64 | |
install_deps: "choco install mingw" | |
build_command: "gcc -Ofast prime_finder.c -o prime_finder_x64.exe -lm" | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Install Dependencies | |
run: | | |
${{ matrix.install_deps }} | |
shell: bash | |
- name: Build Program | |
run: | | |
${{ matrix.build_command }} | |
shell: bash | |
- name: Set Artifact Name | |
run: | | |
if [ "${{ matrix.arch }}" = "x86" ]; then | |
echo "ARTIFACT_NAME=prime_finder_x86" >> $GITHUB_ENV | |
elif [ "${{ matrix.arch }}" = "x64" ]; then | |
if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
echo "ARTIFACT_NAME=prime_finder_x64.exe" >> $GITHUB_ENV | |
else | |
echo "ARTIFACT_NAME=prime_finder_x64" >> $GITHUB_ENV | |
fi | |
fi | |
shell: bash | |
- name: Create Unique Tag | |
run: echo "UNIQUE_TAG=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.UNIQUE_TAG }} | |
release_name: Release ${{ env.UNIQUE_TAG }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Artifact | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./${{ env.ARTIFACT_NAME }} | |
asset_name: ${{ matrix.arch }}-${{ matrix.os }} | |
asset_content_type: application/octet-stream |