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: | mkdir output mkdir artifact $outputPath = Join-Path (Pwd) output $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:6.0.403-alpine3.16 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" $tag = '${{ github.event.ref }}'.Replace('refs/tags/', '') Push-Location output chmod +r * chmod +x GetMoarFediverse || true if ('${{ matrix.runtime }}'.StartsWith('win-')) { Compress-Archive -Path * -DestinationPath "../artifact/GetMoarFediverse_$($tag)_${{ matrix.runtime }}.zip" } else { tar -czf ../artifact/GetMoarFediverse_$($tag)_${{ matrix.runtime }}.tgz * } - uses: actions/upload-artifact@v3 with: name: ${{ matrix.runtime }} path: artifact/* create-release: runs-on: ubuntu-latest needs: [ create-artifact ] steps: - uses: actions/download-artifact@master with: name: win-x64 path: artifacts/win-x64 - uses: actions/download-artifact@master with: name: linux-x64 path: artifacts/linux-x64 - uses: actions/download-artifact@master with: name: linux-arm64 path: artifacts/linux-arm64 - uses: actions/download-artifact@master 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 ] 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', '') docker build . --tag ghcr.io/g3rv4/getmoarfediverse:latest --tag "ghcr.io/g3rv4/getmoarfediverse:$version" docker push ghcr.io/g3rv4/getmoarfediverse:latest docker push "ghcr.io/g3rv4/getmoarfediverse:$version"