📌 Release build #22
This file contains hidden or 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: Release build | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release_notes: | |
| description: 'Release notes' | |
| required: true | |
| version: | |
| description: "Release version (leave empty for automatic versioning)" | |
| run-name: '📌 Release build ${{ inputs.version }}' | |
| env: | |
| PROJECT_PATH: src/WTelegramClient.csproj | |
| CONFIGURATION: Release | |
| PACKAGES_PATH: packages | |
| RELEASE_NOTES: ${{ inputs.release_notes }} | |
| VERSION: ${{ inputs.version }} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # For git tag | |
| id-token: write # enable GitHub OIDC token issuance for this job | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 100 | |
| - name: Determine version | |
| if: ${{ env.VERSION == '' }} | |
| run: | | |
| git fetch --depth=100 --tags | |
| DESCR_TAG=$(git describe --tags --long) # get the last tag-commits_since-sha | |
| LAST_TAG=${DESCR_TAG%%-*} # extract the last tag | |
| NEXT_VERSION=${LAST_TAG%.*}.$((${LAST_TAG##*.} + 1)) # increment the last number | |
| RELEASE_VERSION=${{vars.RELEASE_VERSION}} # construct the version if we were to respect the RELEASE_VERSION variable | |
| VERSION=`echo -e "$RELEASE_VERSION\n$NEXT_VERSION" | sort -V | tail -n1` # pick the higher version among the two | |
| echo Last tag: $LAST_TAG · Next version: $NEXT_VERSION · Release version: $RELEASE_VERSION · Build version: $VERSION | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: Pack | |
| run: | | |
| RELEASE_NOTES=${RELEASE_NOTES//|/%0A} | |
| RELEASE_NOTES=${RELEASE_NOTES// - /%0A- } | |
| RELEASE_NOTES=${RELEASE_NOTES// • /%0A• } | |
| RELEASE_NOTES=${RELEASE_NOTES// /%0A%0A} | |
| RELEASE_NOTES=${RELEASE_NOTES//$'\n'/%0A} | |
| RELEASE_NOTES=${RELEASE_NOTES//\"/%22} | |
| RELEASE_NOTES=${RELEASE_NOTES//,/%2C} | |
| RELEASE_NOTES=${RELEASE_NOTES//;/%3B} | |
| dotnet pack $PROJECT_PATH --configuration $CONFIGURATION -p:Version=$VERSION -p:ReleaseNotes="$RELEASE_NOTES" --output $PACKAGES_PATH | |
| # - name: Upload artifact | |
| # uses: actions/upload-artifact@v4 | |
| # with: | |
| # name: packages | |
| # path: $PACKAGES_PATH/*.nupkg | |
| - name: NuGet login (OIDC → temp API key) | |
| uses: NuGet/login@v1 | |
| id: login | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - name: Nuget push | |
| run: dotnet nuget push $PACKAGES_PATH/*.nupkg --api-key ${{steps.login.outputs.NUGET_API_KEY}} --skip-duplicate --source https://api.nuget.org/v3/index.json | |
| - name: Git tag | |
| run: | | |
| git tag $VERSION | |
| git push --tags | |
| - name: Deployment Notification | |
| env: | |
| JSON: | | |
| { | |
| "status": "success", "complete": true, "commitMessage": ${{ toJSON(env.RELEASE_NOTES) }}, | |
| "message": "{ \"commitId\": \"${{ github.sha }}\", \"buildNumber\": \"${{ env.VERSION }}\", \"repoName\": \"${{ github.repository }}\"}" | |
| } | |
| run: | | |
| curl -X POST -H "Content-Type: application/json" -d "$JSON" ${{ secrets.DEPLOYED_WEBHOOK }} |