Fix download-artifact (#47) #33
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: Create Release | |
on: | |
push: | |
tags: | |
- v* | |
jobs: | |
create-artifact: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
runtime: [ win-x64, linux-x64, linux-arm64, osx-x64 ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Build artifact | |
shell: pwsh | |
run: | | |
$tag = '${{ github.event.ref }}'.Replace('refs/tags/', '') | |
$zipDirectory = "GetMoarFediverse-$($tag)" | |
mkdir $tag | |
mkdir artifact | |
$outputPath = Join-Path (Pwd) $zipDirectory | |
$srcPath = Join-Path (Pwd) src | |
$uid = sh -c 'id -u' | |
$gid = sh -c 'id -g' | |
docker run -v "$($outputPath):/var/output" -v "$($srcPath):/var/src" mcr.microsoft.com/dotnet/sdk:8.0.100-1-alpine3.18 ash -c "dotnet publish -r ${{ matrix.runtime }} --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -c Release /var/src/GetMoarFediverse.csproj -o /var/output && chown -R $($uid):$($gid) /var/output" | |
Push-Location $outputPath | |
chmod +r * | |
chmod +x GetMoarFediverse || true | |
Pop-Location | |
if ('${{ matrix.runtime }}'.StartsWith('win-')) { | |
Compress-Archive -Path $zipDirectory -DestinationPath "artifact/GetMoarFediverse_${{ matrix.runtime }}.zip" | |
} else { | |
tar -czf artifact/GetMoarFediverse_${{ matrix.runtime }}.tgz $zipDirectory | |
} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.runtime }} | |
path: artifact/* | |
create-release: | |
runs-on: ubuntu-latest | |
needs: [ create-artifact ] | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: win-x64 | |
path: artifacts/win-x64 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: linux-x64 | |
path: artifacts/linux-x64 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: linux-arm64 | |
path: artifacts/linux-arm64 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: osx-x64 | |
path: artifacts/osx-x64 | |
- name: Release | |
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 | |
with: | |
generate_release_notes: true | |
fail_on_unmatched_files: true | |
files: | | |
artifacts/win-x64/*.zip | |
artifacts/linux-x64/*.tgz | |
artifacts/linux-arm64/*.tgz | |
artifacts/osx-x64/*.tgz | |
create-docker-image: | |
runs-on: ubuntu-latest | |
needs: [ create-release ] | |
strategy: | |
matrix: | |
architecture: [ amd64, arm64v8 ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push the Docker image | |
shell: pwsh | |
run: | | |
$version = '${{ github.event.ref }}'.Replace('refs/tags/', '').Replace('v', '') | |
if ('${{ matrix.architecture }}' -eq 'arm64v8') { | |
sudo apt-get install qemu binfmt-support qemu-user-static | |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | |
sed -i 's/8.0.100-1-alpine3.18/8.0.100-alpine3.18/' Dockerfile | |
} | |
docker build . -t ghcr.io/g3rv4/getmoarfediverse:latest-${{ matrix.architecture }} --build-arg ARCH=${{ matrix.architecture }} | |
docker tag ghcr.io/g3rv4/getmoarfediverse:latest-${{ matrix.architecture }} ghcr.io/g3rv4/getmoarfediverse:$version-${{ matrix.architecture }} | |
docker push ghcr.io/g3rv4/getmoarfediverse:latest-${{ matrix.architecture }} | |
docker push ghcr.io/g3rv4/getmoarfediverse:$version-${{ matrix.architecture }} | |
if ('${{ matrix.architecture }}' -eq 'amd64') { | |
docker tag ghcr.io/g3rv4/getmoarfediverse:latest-${{ matrix.architecture }} ghcr.io/g3rv4/getmoarfediverse:latest | |
docker push ghcr.io/g3rv4/getmoarfediverse:latest | |
} |