Skip to content

Update suzuki-shunsuke/github-action-renovate-config-validator action… #84

Update suzuki-shunsuke/github-action-renovate-config-validator action…

Update suzuki-shunsuke/github-action-renovate-config-validator action… #84

Workflow file for this run

name: Publish and Release
on:
push:
branches: [ main ]
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: ✨ checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🔨 set up .net 7
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: 👌 extract version
id: extract_version
shell: pwsh
run: |
$csprojPath = "src/GraphQLToKarate.CommandLine/GraphQLToKarate.CommandLine.csproj"
$csproj = [xml](Get-Content -Path $csprojPath)
$version = $csproj.Project.PropertyGroup.Version
echo "Version: $version"
echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: 🔎 check if version changed
id: version_changed
run: |
git fetch origin
CS_PROJ_FILE="src/GraphQLToKarate.CommandLine/GraphQLToKarate.CommandLine.csproj"
git show HEAD^:$CS_PROJ_FILE > old_csproj.xml
cp $CS_PROJ_FILE new_csproj.xml
OLD_VERSION=$(grep -oP '<Version>\K(.*?)(?=</Version>)' old_csproj.xml)
NEW_VERSION=$(grep -oP '<Version>\K(.*?)(?=</Version>)' new_csproj.xml)
VERSION_CHANGED=0
if [ "$OLD_VERSION" = "$NEW_VERSION" ]; then
echo "The <Version> tag has not changed."
else
echo "The <Version> tag has changed from $OLD_VERSION to $NEW_VERSION."
VERSION_CHANGED=1
fi
echo "VERSION_CHANGED=$VERSION_CHANGED" >> $GITHUB_ENV
- name: 🔨 build and publish
if: env.VERSION_CHANGED == '1'
run: |
# Linux
dotnet publish src/GraphQLToKarate.CommandLine/GraphQLToKarate.CommandLine.csproj --configuration Release --output ./publish/linux-x64 --self-contained true --runtime linux-x64 --force /p:PublishReadyToRun=true /p:PublishSingleFile=true /p:DebugType=None /p:DebugSymbols=false /p:GenerateDocumentationFile=false /p:TreatWarningsAsErrors=false
zip -j -r ./publish/linux-x64.zip ./publish/linux-x64/*
# Windows
dotnet publish src/GraphQLToKarate.CommandLine/GraphQLToKarate.CommandLine.csproj --configuration Release --output ./publish/win-x64 --self-contained true --runtime win-x64 --force /p:PublishReadyToRun=true /p:PublishSingleFile=true /p:DebugType=None /p:DebugSymbols=false /p:GenerateDocumentationFile=false /p:TreatWarningsAsErrors=false
zip -j -r ./publish/win-x64.zip ./publish/win-x64/*
# MacOS
dotnet publish src/GraphQLToKarate.CommandLine/GraphQLToKarate.CommandLine.csproj --configuration Release --output ./publish/osx-x64 --self-contained true --runtime osx-x64 --force /p:PublishReadyToRun=true /p:PublishSingleFile=true /p:DebugType=None /p:DebugSymbols=false /p:GenerateDocumentationFile=false /p:TreatWarningsAsErrors=false
zip -j -r ./publish/osx-x64.zip ./publish/osx-x64/*
- name: 🔨 set up python
if: env.VERSION_CHANGED == '1'
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: 📢 extract release notes
if: env.VERSION_CHANGED == '1'
run: |
python scripts/extract_changelog.py CHANGELOG.md latest_release.md
- name: 📑 create github release
if: env.VERSION_CHANGED == '1'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.VERSION }}
release_name: Release v${{ env.VERSION }}
draft: false
prerelease: false
body_path: latest_release.md
- name: 🔼 upload linux artifacts
if: env.VERSION_CHANGED == '1'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./publish/linux-x64.zip
asset_name: graphql-to-karate-${{ env.VERSION }}-linux-x64.zip
asset_content_type: application/zip
- name: 🔼 upload windows artifacts
if: env.VERSION_CHANGED == '1'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./publish/win-x64.zip
asset_name: graphql-to-karate-${{ env.VERSION }}-win-x64.zip
asset_content_type: application/zip
- name: 🔼 upload macos artifacts
if: env.VERSION_CHANGED == '1'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./publish/osx-x64.zip
asset_name: graphql-to-karate-${{ env.VERSION }}-osx-x64.zip
asset_content_type: application/zip
- name: 💌 publish nuget
uses: alirezanet/publish-nuget@v3.1.0
with:
PROJECT_FILE_PATH: src/GraphQLToKarate.CommandLine/GraphQLToKarate.CommandLine.csproj
TAG_COMMIT: false
NUGET_KEY: ${{secrets.NUGET_API_KEY}}