Publish pipeline #17
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: Publish pipeline | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| build_pre_release: | |
| description: 'Mark as pre-release' | |
| required: true | |
| default: false | |
| type: boolean | |
| version_tag: | |
| description: 'The version number formatted as X.X.X' | |
| default: '0.1.0' | |
| required: true | |
| type: string | |
| permissions: write-all | |
| jobs: | |
| test-pipeline: | |
| name: 'Invoke the test pipeline' | |
| uses: ./.github/workflows/test-pipeline.yml | |
| secrets: inherit | |
| #Deploy package | |
| publish-package: | |
| name: 'Build and publish package' | |
| needs: test-pipeline | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: 'RenameVersionTag' | |
| shell: bash | |
| run: | | |
| PRE_REL_STR='-pre' | |
| EMPTY_STR= | |
| if ${{ github.event.inputs.build_pre_release }} | |
| then | |
| echo "prerelease_append=$PRE_REL_STR" >> $GITHUB_ENV | |
| else | |
| echo "prerelease_append=$EMPTY_STR" >> $GITHUB_ENV | |
| fi | |
| - name: Set .csproj version to ${{ github.event.inputs.version_tag }}${{ env.prerelease_append }} | |
| run: | | |
| sed -i 's/<Version>[0-9].[0-9].[0-9]<\/Version>/<Version>${{ github.event.inputs.version_tag }}${{ env.prerelease_append }}<\/Version>/g' MewtocolNet/MewtocolNet.csproj | |
| less MewtocolNet/MewtocolNet.csproj | |
| - name: 'Bump version and push tag v${{ github.event.inputs.version_tag }}${{ env.prerelease_append }}' | |
| id: tag_version | |
| uses: mathieudutour/github-tag-action@v6.1 | |
| with: | |
| tag_prefix: v | |
| custom_tag: ${{ github.event.inputs.version_tag }}${{ env.prerelease_append }} | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: 'Build Changelog' | |
| uses: mikepenz/release-changelog-builder-action@v3 | |
| id: github_release_log | |
| with: | |
| commitMode: true | |
| configurationJson: | | |
| { | |
| "template": "#{{CHANGELOG}}\n\n<details>\n<summary>Uncategorized</summary>\n\n#{{UNCATEGORIZED}}\n</details>", | |
| "pr_template": "- #{{TITLE}} #{{MERGE_SHA}}", | |
| "trim_values" : true, | |
| "ignore_labels": [ "ignore" ], | |
| "categories": [ | |
| { | |
| "title": "## 🚀 Added Features", | |
| "labels": ["feature", "features", "add", "added", "implemented", "impl", "new"] | |
| }, | |
| { | |
| "title": "## 🔃 Changed Features", | |
| "labels": ["change", "changed"] | |
| }, | |
| { | |
| "title": "## ❌ Removed Features", | |
| "labels": ["remove", "removed"] | |
| }, | |
| { | |
| "title": "## 🪲 Fixes", | |
| "labels": ["fix", "fixed", "fixes"] | |
| }, | |
| { | |
| "title": "## 📖 Documentation", | |
| "labels": ["doc", "docs", "documentation"] | |
| }, | |
| { | |
| "title": "## 🧪 Tests", | |
| "labels": ["test", "tests", "unittests"] | |
| }, | |
| { | |
| "title": "## 📦 Dependencies", | |
| "labels": ["dependencies", "package", "nuget"] | |
| }, | |
| { | |
| "title": "## 🏠 Householding", | |
| "labels": ["upgraded", "upgrade", "update", "clear", "delete", "deleted", "version"] | |
| }, | |
| { | |
| "title": "## 🌎 Localization", | |
| "labels": ["lang", "language", "localization", "locale", "translation", "translations"] | |
| }, | |
| { | |
| "title": "## 💬 Other", | |
| "labels": ["other"] | |
| } | |
| ], | |
| "duplicate_filter": { | |
| "pattern": ".*", | |
| "on_property": "title", | |
| "method": "match" | |
| }, | |
| "transformers": [ | |
| { | |
| "pattern": "^.*?\\s*\\(?(\\w+)\\)? (.*)", | |
| "target": "- $1 $2" | |
| } | |
| ], | |
| "label_extractor": [ | |
| { | |
| "pattern": "^.*?\\s*\\(?(\\w{3,})\\)? (.*)", | |
| "target": "$1", | |
| "flags": "gis" | |
| } | |
| ] | |
| } | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v2 | |
| with: | |
| dotnet-version: '6.0.x' | |
| - name: Restore dependencies | |
| run: dotnet restore ./MewtocolNet/MewtocolNet.csproj | |
| - name: Build as ${{ github.event.inputs.version_tag }}${{ env.prerelease_append }} | |
| run: dotnet build "MewtocolNet" --no-incremental -c:Release | |
| - name: Pack as ${{ github.event.inputs.version_tag }}${{ env.prerelease_append }} | |
| run: dotnet pack "MewtocolNet" -c:Release | |
| - name: Publish as ${{ github.event.inputs.version_tag }}${{ env.prerelease_append }} | |
| run: | | |
| cd '${{ github.workspace }}/Builds/MewtocolNet' | |
| ls -l | |
| dotnet nuget push "*.nupkg" --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }} --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" | |
| dotnet nuget push "*.nupkg" --skip-duplicate --api-key ${{ secrets.NUGET_TOKEN }} --source "https://api.nuget.org/v3/index.json" | |
| - name: 'Create Release v${{ github.event.inputs.version_tag }}${{ env.prerelease_append }}' | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ github.event.inputs.version_tag }}${{ env.prerelease_append }} | |
| release_name: v${{ github.event.inputs.version_tag }}${{ env.prerelease_append }} | |
| body: | | |
| ## Changelog | |
| ${{ steps.github_release_log.outputs.changelog }} | |
| **Total commits:** ${{ steps.github_release_log.outputs.commits }} | |
| draft: false | |
| prerelease: ${{ github.event.inputs.build_pre_release }} | |
| - name: 'Upload package to latest release' | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| with: | |
| upload_url: "${{ steps.create_release.outputs.upload_url }}" | |
| asset_path: ${{ github.workspace }}/Builds/MewtocolNet/Mewtocol.NET.${{ github.event.inputs.version_tag }}${{ env.prerelease_append }}.nupkg | |
| asset_name: Mewtocol.NET.${{ github.event.inputs.version_tag }}${{ env.prerelease_append }}.nupkg | |
| asset_content_type: application/zip |