|
| 1 | +name: release |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + branch: |
| 6 | + description: 'Branch to release' |
| 7 | + required: true |
| 8 | + version: |
| 9 | + description: 'Release version' |
| 10 | + required: true |
| 11 | + nextVersion: |
| 12 | + description: 'Next version after release (ALPHA VersionSuffix will be added automatically)' |
| 13 | + required: true |
| 14 | +jobs: |
| 15 | + release: |
| 16 | + name: Release |
| 17 | + runs-on: ubuntu-latest |
| 18 | + permissions: |
| 19 | + issues: write |
| 20 | + contents: write |
| 21 | + deployments: write |
| 22 | + id-token: write |
| 23 | + steps: |
| 24 | + - name: Checkout Code |
| 25 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2 |
| 26 | + with: |
| 27 | + ssh-key: ${{ secrets.RELEASE_DEPLOY_KEY }} |
| 28 | + lfs: true |
| 29 | + fetch-depth: 0 |
| 30 | + ref: ${{ github.event.inputs.branch }} |
| 31 | + |
| 32 | + - name: 🛠️ Setup .NET |
| 33 | + uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 #v4.3.1 |
| 34 | + with: |
| 35 | + global-json-file: global.json |
| 36 | + |
| 37 | + - name: Set release version |
| 38 | + run: | |
| 39 | + # Comment alpha version suffix and force version prefix to release version |
| 40 | + sed -i '/<VersionSuffix>alpha<\/VersionSuffix>/ s|.*|<!-- & -->|' Directory.Build.props |
| 41 | + sed -i "s|<VersionPrefix>.*</VersionPrefix>|<VersionPrefix>${{ github.event.inputs.version }}</VersionPrefix>|" Directory.Build.props |
| 42 | +
|
| 43 | + - name: 🔧 Restore .NET Tools |
| 44 | + run: dotnet tool restore |
| 45 | + |
| 46 | + - name: 🔧 Restore dependencies |
| 47 | + run: dotnet restore |
| 48 | + |
| 49 | + - name: 🏗 Build |
| 50 | + run: dotnet build --configuration Release --no-restore |
| 51 | + |
| 52 | + - name: Commit, push and tag changes |
| 53 | + run: | |
| 54 | + git config user.name "microcks-bot" |
| 55 | + git config user.email "[email protected]" |
| 56 | + git commit -S -m "chore: Releasing version ${{ github.event.inputs.version }}" . |
| 57 | + git tag ${{ github.event.inputs.version }} |
| 58 | + git push origin ${{ github.event.inputs.version }} |
| 59 | +
|
| 60 | + - name: Generate SBOM |
| 61 | + run: | |
| 62 | + curl -Lo $RUNNER_TEMP/sbom-tool https://github.com/microsoft/sbom-tool/releases/latest/download/sbom-tool-linux-x64 |
| 63 | + chmod +x $RUNNER_TEMP/sbom-tool |
| 64 | + $RUNNER_TEMP/sbom-tool generate -b ./src/Microcks.Testcontainers/obj/Release/net6.0 -bc . -pn Microcks.Testcontainers -pv ${{ github.event.inputs.version }} -ps Microcks -nsb https://microcks.io |
| 65 | + $RUNNER_TEMP/sbom-tool generate -b ./src/Microcks.Testcontainers/obj/Release/net8.0 -bc . -pn Microcks.Testcontainers -pv ${{ github.event.inputs.version }} -ps Microcks -nsb https://microcks.io |
| 66 | + cp ./src/Microcks.Testcontainers/obj/Release/net6.0/_manifest/spdx_2.2/manifest.spdx.json ./Microcks.Testcontainers-net6.0.spdx-sbom.json |
| 67 | + cp ./src/Microcks.Testcontainers/obj/Release/net8.0/_manifest/spdx_2.2/manifest.spdx.json ./Microcks.Testcontainers-net8.0.spdx-sbom.json |
| 68 | +
|
| 69 | + - name: Publish release with JReleaser |
| 70 | + uses: jreleaser/release-action@v2 |
| 71 | + env: |
| 72 | + JRELEASER_PROJECT_VERSION: ${{ github.event.inputs.version }} |
| 73 | + JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} |
| 74 | + JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} |
| 75 | + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} |
| 76 | + JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + |
| 78 | + # Persist logs |
| 79 | + - name: JReleaser release output |
| 80 | + if: always() |
| 81 | + uses: actions/upload-artifact@v4 |
| 82 | + with: |
| 83 | + name: jreleaser-release |
| 84 | + path: | |
| 85 | + target/jreleaser/trace.log |
| 86 | + target/jreleaser/output.properties |
| 87 | +
|
| 88 | + - name: Set next iteration version |
| 89 | + run: | |
| 90 | + sed -i "s|<VersionPrefix>.*</VersionPrefix>|<VersionPrefix>${{ github.event.inputs.nextVersion }}</VersionPrefix>|" Directory.Build.props |
| 91 | + sed -i 's|<!-- \(.*<VersionSuffix>alpha</VersionSuffix>.*\) -->|\1|' Directory.Build.props |
| 92 | +
|
| 93 | + - name: Commit, push and tag changes |
| 94 | + run: | |
| 95 | + git commit -S -m "chore: Setting ALPHA VersionSuffix to ${{ github.event.inputs.nextVersion }}" . |
| 96 | + git push origin ${{ github.event.inputs.branch }} |
| 97 | +
|
| 98 | + |
0 commit comments