|
| 1 | +name: Create Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version_type: |
| 7 | + type: choice |
| 8 | + description: Semantic Version Type |
| 9 | + options: |
| 10 | + - major |
| 11 | + - minor |
| 12 | + - patch |
| 13 | + - no-version-update |
| 14 | + |
| 15 | + pre_release: |
| 16 | + type: choice |
| 17 | + description: Pre Release? |
| 18 | + options: |
| 19 | + - stable |
| 20 | + - alpha |
| 21 | + - beta |
| 22 | + - rc |
| 23 | + |
| 24 | +jobs: |
| 25 | + release-it: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - uses: tibdex/github-app-token@v1 |
| 29 | + id: generate-token |
| 30 | + with: |
| 31 | + app_id: ${{ secrets.RELEASE_BOT_APP_ID }} |
| 32 | + private_key: ${{ secrets.RELEASE_BOT_APP_PRIVATE_KEY }} |
| 33 | + |
| 34 | + - name: checkout |
| 35 | + uses: actions/checkout@v3 |
| 36 | + with: |
| 37 | + token: ${{ steps.generate-token.outputs.token }} |
| 38 | + # we need everything so release-it can compare the current version with the latest tag |
| 39 | + fetch-depth: 0 |
| 40 | + |
| 41 | + - name: initialize mandatory git config |
| 42 | + run: | |
| 43 | + git config user.name "GitHub Release Bot" |
| 44 | + git config user.email release-bot@neolution.ch |
| 45 | +
|
| 46 | + - name: install @release-it/keep-a-changelog |
| 47 | + run: npm install -g release-it @release-it/keep-a-changelog |
| 48 | + |
| 49 | + - name: run release-it |
| 50 | + run: | |
| 51 | + params=() |
| 52 | +
|
| 53 | + if [[ ${{ github.event.inputs.version_type }} != "no-version-update" ]]; then |
| 54 | + params+=(${{ github.event.inputs.version_type }}) |
| 55 | + fi |
| 56 | +
|
| 57 | + if [[ ${{ github.event.inputs.pre_release }} != "stable" ]]; then |
| 58 | + params+=(--preRelease=${{ github.event.inputs.pre_release }}) |
| 59 | + params+=(--plugins.@release-it/keep-a-changelog.keepUnreleased) |
| 60 | + params+=(--no-plugins.@release-it/keep-a-changelog.strictLatest) |
| 61 | + fi |
| 62 | +
|
| 63 | + params+=(--ci) |
| 64 | +
|
| 65 | + release-it -y "${params[@]}" |
| 66 | + env: |
| 67 | + GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} |
| 68 | + |
| 69 | + - name: Get next release number |
| 70 | + run: | |
| 71 | + echo "RELEASE_VERSION=$(release-it --release-version --dry-run)" >> $GITHUB_ENV |
| 72 | +
|
| 73 | + - name: Print release version |
| 74 | + run: echo "The next release number is ${{ env.RELEASE_VERSION }}" |
| 75 | + |
| 76 | + - name: Replace version number in nuspec files |
| 77 | + run: 'sed -i -e "s/{{NuGetVersion}}/$GITVERSION_NUGETVERSION/g" *.nuspec' |
| 78 | + |
| 79 | + - name: Setup NuGet.exe for use with actions |
| 80 | + uses: NuGet/setup-nuget@v1.0.5 |
| 81 | + |
| 82 | + - name: Create main package |
| 83 | + run: nuget pack Neolution.CodeAnalysis.nuspec |
| 84 | + |
| 85 | + - name: Create TestsRuleset package |
| 86 | + run: nuget pack Neolution.CodeAnalysis.TestsRuleset.nuspec |
| 87 | + |
| 88 | + - name: Push all packages to Nuget.org |
| 89 | + run: dotnet nuget push --skip-duplicate -s $ARTIFACTS_FEED_URL -k $NUGET_AUTH_TOKEN **/*.nupkg |
| 90 | + env: |
| 91 | + NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY_NEOLUTION }} |
0 commit comments