|
1 | 1 | name: Release |
2 | | - |
3 | 2 | on: |
4 | 3 | workflow_dispatch: |
5 | 4 | inputs: |
6 | 5 | release-version: |
7 | | - description: "Release version" |
8 | | - default: "1.0.0" |
| 6 | + description: 'Release version' |
| 7 | + required: true |
| 8 | + default: '0.0.1' |
| 9 | + push: |
| 10 | + tags: |
| 11 | + - '*' |
| 12 | + |
| 13 | +env: |
| 14 | + release-version: ${{ github.event.inputs.release-version || github.ref_name }} |
9 | 15 |
|
10 | 16 | jobs: |
| 17 | + test: |
| 18 | + name: Test ${{github.ref_name}} |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + ref: main |
| 27 | + |
| 28 | + - name: Check permissions |
| 29 | + if: github.event.inputs.release-version && github.actor != 'Serg046' |
| 30 | + env: |
| 31 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + run: | |
| 33 | + gh run cancel ${{ github.run_id }} && gh run watch ${{ github.run_id }} |
| 34 | + exit 0 |
| 35 | +
|
| 36 | + - name: Install .NET SDK |
| 37 | + uses: actions/setup-dotnet@v4 |
| 38 | + with: |
| 39 | + dotnet-version: | |
| 40 | + 2.x |
| 41 | + 9.x |
11 | 42 |
|
12 | | - build-and-test: |
13 | | - |
14 | | - runs-on: windows-latest |
| 43 | + - name: Install libssl |
| 44 | + run: | |
| 45 | + wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb |
| 46 | + sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb |
| 47 | +
|
| 48 | + - name: Test |
| 49 | + run: dotnet test |
| 50 | + |
| 51 | + release: |
| 52 | + name: Release ${{github.ref_name}} |
| 53 | + needs: test |
| 54 | + runs-on: ubuntu-latest |
15 | 55 |
|
16 | 56 | steps: |
17 | 57 | - name: Checkout |
18 | 58 | uses: actions/checkout@v4 |
19 | 59 | with: |
20 | 60 | fetch-depth: 0 |
| 61 | + ref: main |
21 | 62 |
|
22 | | - - name: Build and test |
23 | | - run: dotnet test |
| 63 | + - name: Set the package release version |
| 64 | + uses: jacobtomlinson/gha-find-replace@v3 |
| 65 | + with: |
| 66 | + find: "<Version>.*</Version>" |
| 67 | + replace: "<Version>${{env.release-version}}</Version>" |
| 68 | + include: "dotMap/dotMap.csproj" |
| 69 | + regex: true |
| 70 | + |
| 71 | + - name: Build and pack |
| 72 | + run: dotnet pack dotMap/dotMap.csproj -c Release |
| 73 | + |
| 74 | + - name: Publish artifacts |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + with: |
| 77 | + name: NuGet packages |
| 78 | + path: dotMap/**/*.nupkg |
| 79 | + |
| 80 | + - name: Save and push the new version |
| 81 | + run: | |
| 82 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 83 | + git config --local user.name "github-actions[bot]" |
| 84 | + git add dotMap/dotMap.csproj |
| 85 | + git commit -m "Release v${{env.release-version}}" |
| 86 | + git push |
0 commit comments