ci: add upload artifact job #25
Workflow file for this run
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: Release the Artifact for Multiple OS | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build-and-release: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
outputs: | |
tag: ${{ steps.extract_tag.outputs.tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Extract tag name | |
id: extract_tag | |
run: | | |
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
- name: Setup dotnet SDK | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Build and Publish for Linux | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
make publish | |
mkdir -p ./bin/${{ matrix.os }} | |
mv ./Clone.Console/bin/Release/net8.0/linux-x64/publish/Clone.Console ./bin/${{ matrix.os }}/clone | |
sha256sum ./bin/${{ matrix.os }}/clone > ./bin/${{ matrix.os }}/sha256sum.txt | |
- name: Build and Publish for macOS | |
if: matrix.os == 'macos-latest' | |
run: | | |
make publish | |
mkdir -p ./bin/${{ matrix.os }} | |
mv ./Clone.Console/bin/Release/net8.0/osx-x64/publish/Clone.Console ./bin/${{ matrix.os }}/clone | |
shasum -a 256 ./bin/${{ matrix.os }}/clone > ./bin/${{ matrix.os }}/sha256sum.txt | |
- name: Build and Publish for Windows | |
if: matrix.os == 'windows-latest' | |
run: | | |
.\Publish.ps1 | |
New-Item -Path .\bin\${{ matrix.os }} -ItemType Directory -Force | |
Move-Item .\Clone.Console\bin\Release\net8.0\win-x64\publish\Clone.Console.exe .\bin\${{ matrix.os }}\clone.exe | |
$hash = (Get-FileHash .\bin\${{ matrix.os }}\clone.exe -Algorithm SHA256).Hash | |
echo $hash > .\bin\${{ matrix.os }}\sha256sum.txt | |
shell: pwsh | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.os }}-release | |
path: ./bin/${{ matrix.os }}/* | |
upload-artifacts: | |
needs: build-and-release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
- name: Zip the artifacts | |
run: | | |
zip -jr macos-latest-release.zip ./macos-latest-release | |
zip -jr ubuntu-latest-release.zip ./ubuntu-latest-release | |
zip -jr windows-latest-release.zip ./windows-latest-release | |
- name: Set up GitHub CLI | |
run: | | |
sudo apt update | |
sudo apt install gh -y | |
- name: Upload artifacts to the release | |
run: | | |
TAG_NAME=${GITHUB_REF#refs/tags/} | |
gh release create $TAG_NAME --notes "Release $TAG_NAME" | |
gh release upload "$TAG_NAME" macos-latest-release.zip --clobber | |
gh release upload "$TAG_NAME" ubuntu-latest-release.zip --clobber | |
gh release upload "$TAG_NAME" windows-latest-release.zip --clobber | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |