Create release assets #26
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 assets | |
on: | |
release: | |
types: | |
- created | |
jobs: | |
release: | |
name: Build release and publish assets | |
runs-on: ubuntu-latest | |
container: mono:latest | |
steps: | |
- name: Installing build dependencies | |
run: apt-get update && apt-get install -y wget jq | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '7' | |
- name: Restore, build, and test | |
run: | | |
dotnet build -c Release | |
- name: Smoke test the validator outside the build dir | |
run: | | |
cp _build/KSPMMCfgValidator/Release/bin/net48/Repack/KSPMMCfgValidator.exe . | |
chmod a+x KSPMMCfgValidator.exe | |
mono ./KSPMMCfgValidator.exe | |
- name: Get release data | |
id: release_data | |
run: | | |
echo -n 'upload_url=' >> $GITHUB_OUTPUT | |
curl -fsSL https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq -rM '.upload_url' >> $GITHUB_OUTPUT | |
echo -n 'nupkg_basename=' >> $GITHUB_OUTPUT | |
basename _build/KSPMMCfgParser/Release/bin/KSPMMCfgParser.*.nupkg >> $GITHUB_OUTPUT | |
- name: Upload parser nupkg release asset | |
uses: actions/upload-release-asset@v1.0.1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.release_data.outputs.upload_url }} | |
asset_path: _build/KSPMMCfgParser/Release/bin/${{ steps.release_data.outputs.nupkg_basename }} | |
asset_name: ${{ steps.release_data.outputs.nupkg_basename }} | |
asset_content_type: application/vnd.microsoft.portable-executable | |
- name: Upload validator exe release asset | |
uses: actions/upload-release-asset@v1.0.1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.release_data.outputs.upload_url }} | |
asset_path: _build/KSPMMCfgValidator/Release/bin/net48/Repack/KSPMMCfgValidator.exe | |
asset_name: KSPMMCfgValidator.exe | |
asset_content_type: application/vnd.microsoft.portable-executable | |
- name: Publish parser to NuGet | |
env: | |
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
if: env.NUGET_API_KEY | |
run: | | |
curl -o nuget.exe -L 'https://dist.nuget.org/win-x86-commandline/v5.6.0/nuget.exe' | |
mono nuget.exe push _build/KSPMMCfgParser/Release/bin/${{ steps.release_data.outputs.nupkg_basename }} ${{ secrets.NUGET_API_KEY }} -Source https://api.nuget.org/v3/index.json -SkipDuplicate | |
- name: Generate validator image and publish to Docker Hub | |
env: | |
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | |
if: env.DOCKERHUB_USERNAME && env.DOCKERHUB_PASSWORD | |
run: | | |
curl -fsSL https://get.docker.com -o get-docker.sh | |
sh get-docker.sh | |
echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin | |
mkdir -p _build/docker/KSPMMCfgValidator | |
cp KSPMMCfgValidator/Dockerfile _build/KSPMMCfgValidator/Release/bin/*/KSPMMCfgValidator.exe _build/docker/KSPMMCfgValidator | |
docker build -t kspckan/kspmmcfgvalidator:latest _build/docker/KSPMMCfgValidator | |
docker push kspckan/kspmmcfgvalidator:latest |