GetMoarFediverse/.github/workflows/create-release.yml

95 lines
3.1 KiB
YAML
Raw Normal View History

2022-12-15 22:32:23 +01:00
name: Create Release
on:
push:
tags:
- v*
jobs:
2022-12-16 05:19:50 +01:00
create-artifact:
2022-12-15 22:32:23 +01:00
runs-on: ubuntu-latest
2022-12-16 05:19:50 +01:00
strategy:
matrix:
2022-12-16 06:07:33 +01:00
runtime: [ win-x64, linux-x64, linux-arm64, osx-x64 ]
2022-12-15 22:32:23 +01:00
steps:
- name: Checkout
uses: actions/checkout@v3
2022-12-16 06:07:33 +01:00
- name: Build artifact
2022-12-15 22:32:23 +01:00
shell: pwsh
run: |
mkdir output
2022-12-16 05:19:50 +01:00
mkdir artifact
2022-12-15 22:32:23 +01:00
$outputPath = Join-Path (Pwd) output
$srcPath = Join-Path (Pwd) src
2022-12-16 05:19:50 +01:00
$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 *
}
2022-12-15 22:32:23 +01:00
- uses: actions/upload-artifact@v3
with:
2022-12-16 05:19:50 +01:00
name: ${{ matrix.runtime }}
path: artifact/*
2022-12-15 22:32:23 +01:00
2022-12-16 05:19:50 +01:00
create-release:
2022-12-15 22:32:23 +01:00
runs-on: ubuntu-latest
2022-12-16 05:19:50 +01:00
needs: [ create-artifact ]
2022-12-15 22:32:23 +01:00
steps:
2022-12-16 05:19:50 +01:00
- uses: actions/download-artifact@master
with:
name: win-x64
path: artifacts/win-x64
- uses: actions/download-artifact@master
2022-12-15 22:32:23 +01:00
with:
2022-12-16 05:19:50 +01:00
name: linux-x64
path: artifacts/linux-x64
2022-12-16 06:07:33 +01:00
- 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
2022-12-16 05:19:50 +01:00
- 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
2022-12-16 06:07:33 +01:00
artifacts/linux-arm64/*.tgz
artifacts/osx-x64/*.tgz
2022-12-15 22:32:23 +01:00
create-docker-image:
runs-on: ubuntu-latest
2022-12-16 05:19:50 +01:00
needs: [ create-release ]
2022-12-15 22:32:23 +01:00
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: |
2022-12-16 05:19:50 +01:00
$version = '${{ github.event.ref }}'.Replace('refs/tags/', '').Replace('v', '')
2022-12-15 22:32:23 +01:00
docker build . --tag ghcr.io/g3rv4/getmoarfediverse:latest --tag "ghcr.io/g3rv4/getmoarfediverse:$version"
docker push ghcr.io/g3rv4/getmoarfediverse:latest
2022-12-16 05:19:50 +01:00
docker push "ghcr.io/g3rv4/getmoarfediverse:$version"