|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + pull-requests: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + check-code: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + # Build entirely in docker |
| 18 | + - uses: docker/setup-qemu-action@v3 |
| 19 | + |
| 20 | + - uses: docker/setup-buildx-action@v3 |
| 21 | + |
| 22 | + - uses: docker/build-push-action@v6 |
| 23 | + with: |
| 24 | + context: ./src |
| 25 | + push: false |
| 26 | + tags: oidc-server-mock:experimental |
| 27 | + platforms: linux/amd64,linux/arm64 |
| 28 | + cache-from: type=gha |
| 29 | + cache-to: type=gha,mode=max |
| 30 | + |
| 31 | + prepare-release: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + needs: [check-code] |
| 34 | + outputs: |
| 35 | + upload_url: ${{ steps.create-release.outputs.upload_url }} |
| 36 | + version: ${{ steps.version.outputs.release }} |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v4 |
| 39 | + |
| 40 | + - name: Configure Git |
| 41 | + run: | |
| 42 | + git config --global user.email "[email protected]" |
| 43 | + git config --global user.name "GitHub Actions" |
| 44 | + |
| 45 | + - name: Un-SNAP |
| 46 | + run: | |
| 47 | + version=$(grep -oPm1 "(?<=<VersionPrefix>)[^<]+" <<< cat src/OpenIdConnectServerMock.csproj) |
| 48 | + new_version=${version::-9} |
| 49 | + sed -i "s/\(<VersionPrefix>\)[^<>]*\(<\/VersionPrefix.*\)/\1$new_version\2/" src/OpenIdConnectServerMock.csproj |
| 50 | + |
| 51 | + - name: Get version |
| 52 | + id: version |
| 53 | + run: | |
| 54 | + version=$(grep -oPm1 "(?<=<VersionPrefix>)[^<]+" <<< cat src/OpenIdConnectServerMock.csproj) |
| 55 | + echo "release=$version" >> $GITHUB_OUTPUT |
| 56 | + echo "releasenumber=${version//[!0-9]/}" >> $GITHUB_OUTPUT |
| 57 | + |
| 58 | + - name: Commit and Push |
| 59 | + run: | |
| 60 | + git add -A |
| 61 | + git commit -m "Release ${{ steps.version.outputs.release }}" |
| 62 | + git push origin |
| 63 | + git tag v${{ steps.version.outputs.release }} |
| 64 | + git push origin --tags |
| 65 | + |
| 66 | + - name: Create Release |
| 67 | + id: create-release |
| 68 | + uses: shogo82148/actions-create-release@v1 |
| 69 | + with: |
| 70 | + tag_name: v${{ steps.version.outputs.release }} |
| 71 | + release_name: v${{ steps.version.outputs.release }} |
| 72 | + commitish: master |
| 73 | + body: | |
| 74 | + ## [Changelog](https://github.com/${{ github.repository }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }}) |
| 75 | + See [Changelog#v${{ steps.version.outputs.release }}](https://github.com/${{ github.repository }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }}) for more information. |
| 76 | +
|
| 77 | + ## Installation |
| 78 | +
|
| 79 | + ### Docker |
| 80 | + Download the image from |
| 81 | + * [DockerHub](https://hub.docker.com/r/xdevsoftware/oidc-server-mock/tags?name=${{ steps.version.outputs.release }}) |
| 82 | + * [GitHub Packages (ghcr.io)](https://github.com/xdev-software/oidc-server-mock/pkgs/container/oidc-server-mock) |
| 83 | +
|
| 84 | + publish-docker: |
| 85 | + runs-on: ubuntu-latest |
| 86 | + needs: [prepare-release] |
| 87 | + permissions: |
| 88 | + packages: write |
| 89 | + contents: read |
| 90 | + attestations: write |
| 91 | + id-token: write |
| 92 | + steps: |
| 93 | + - uses: actions/checkout@v4 |
| 94 | + |
| 95 | + - name: Init Git and pull |
| 96 | + run: | |
| 97 | + git config --global user.email "[email protected]" |
| 98 | + git config --global user.name "GitHub Actions" |
| 99 | + git pull |
| 100 | +
|
| 101 | + - uses: docker/setup-qemu-action@v3 |
| 102 | + |
| 103 | + - uses: docker/setup-buildx-action@v3 |
| 104 | + |
| 105 | + - name: Login to DockerHub |
| 106 | + uses: docker/login-action@v3 |
| 107 | + with: |
| 108 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 109 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 110 | + |
| 111 | + - name: Login to ghcr.io |
| 112 | + uses: docker/login-action@v3 |
| 113 | + with: |
| 114 | + registry: ghcr.io |
| 115 | + username: ${{ github.actor }} |
| 116 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 117 | + |
| 118 | + - name: Extract metadata (tags, labels) for Docker |
| 119 | + id: meta |
| 120 | + uses: docker/metadata-action@v5 |
| 121 | + with: |
| 122 | + images: | |
| 123 | + ${{ secrets.DOCKERHUB_USERNAME }}/oidc-server-mock |
| 124 | + ghcr.io/${{ github.repository }} |
| 125 | + tags: | |
| 126 | + type=semver,pattern={{version}},value=${{ needs.prepare-release.outputs.version }} |
| 127 | + type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare-release.outputs.version }} |
| 128 | + type=semver,pattern={{major}},value=${{ needs.prepare-release.outputs.version }} |
| 129 | + latest |
| 130 | +
|
| 131 | + - uses: docker/build-push-action@v6 |
| 132 | + id: push |
| 133 | + with: |
| 134 | + context: ./src |
| 135 | + push: true |
| 136 | + platforms: linux/amd64,linux/arm64 |
| 137 | + tags: ${{ steps.meta.outputs.tags }} |
| 138 | + labels: ${{ steps.meta.outputs.labels }} |
| 139 | + outputs: type=image,compression=zstd,force-compression=true |
| 140 | + |
| 141 | + - name: Generate artifact attestation (ghcr.io) |
| 142 | + uses: actions/attest-build-provenance@v2 |
| 143 | + with: |
| 144 | + subject-name: ghcr.io/${{ github.repository }} |
| 145 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 146 | + push-to-registry: true |
| 147 | + |
| 148 | + after-release: |
| 149 | + runs-on: ubuntu-latest |
| 150 | + needs: [publish-docker] |
| 151 | + steps: |
| 152 | + - uses: actions/checkout@v4 |
| 153 | + |
| 154 | + - name: Init Git and pull |
| 155 | + run: | |
| 156 | + git config --global user.email "[email protected]" |
| 157 | + git config --global user.name "GitHub Actions" |
| 158 | + git pull |
| 159 | +
|
| 160 | + - name: Inc Version and SNAP |
| 161 | + run: | |
| 162 | + version=$(grep -oPm1 "(?<=<VersionPrefix>)[^<]+" <<< cat src/OpenIdConnectServerMock.csproj) |
| 163 | + new_version="$(echo $version | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}')-SNAPSHOT" |
| 164 | + sed -i "s/\(<VersionPrefix>\)[^<>]*\(<\/VersionPrefix.*\)/\1$new_version\2/" src/OpenIdConnectServerMock.csproj |
| 165 | +
|
| 166 | + - name: Git Commit and Push |
| 167 | + run: | |
| 168 | + git add -A |
| 169 | + git commit -m "Preparing for next development iteration" |
| 170 | + git push origin |
| 171 | + |
| 172 | + - name: pull-request |
| 173 | + env: |
| 174 | + GH_TOKEN: ${{ github.token }} |
| 175 | + run: | |
| 176 | + gh_pr_up() { |
| 177 | + gh pr create "$@" || gh pr edit "$@" |
| 178 | + } |
| 179 | + gh_pr_up -B "develop" \ |
| 180 | + --title "Sync back" \ |
| 181 | + --body "An automated PR to sync changes back" |
0 commit comments