|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + |
| 5 | + # Releases can only be triggered via the action tab |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + prepare-release: |
| 10 | + runs-on: ubuntu-18.04 |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v2 |
| 13 | + with: |
| 14 | + ref: main |
| 15 | + |
| 16 | + - name: Set up JDK 8 |
| 17 | + uses: actions/setup-java@v1 |
| 18 | + with: |
| 19 | + java-version: 8 |
| 20 | + |
| 21 | + - name: Setup git configuration |
| 22 | + run: | |
| 23 | + |
| 24 | + git config --global user.name "Netty Project Bot" |
| 25 | +
|
| 26 | + - name: Install SSH key |
| 27 | + uses: shimataro/ssh-key-action@v2 |
| 28 | + with: |
| 29 | + key: ${{ secrets.SSH_PRIVATE_KEY_PEM }} |
| 30 | + known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }} |
| 31 | + |
| 32 | + # Cache .m2/repository |
| 33 | + - uses: actions/cache@v2 |
| 34 | + env: |
| 35 | + cache-name: release-cache-m2-repository |
| 36 | + with: |
| 37 | + path: ~/.m2/repository |
| 38 | + key: ${{ runner.os }}-pr-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} |
| 39 | + restore-keys: | |
| 40 | + ${{ runner.os }}-pr-${{ env.cache-name }}- |
| 41 | + ${{ runner.os }}-pr- |
| 42 | +
|
| 43 | + - name: Prepare release with Maven |
| 44 | + run: | |
| 45 | + mvn -DpreparationGoals=clean release:prepare -B --file pom.xml -DskipTests=true |
| 46 | + mvn clean |
| 47 | +
|
| 48 | + - name: Checkout tag |
| 49 | + run: ./.github/scripts/release_checkout_tag.sh release.properties |
| 50 | + |
| 51 | + - name: Upload workspace |
| 52 | + uses: actions/upload-artifact@v2 |
| 53 | + with: |
| 54 | + name: prepare-release-workspace |
| 55 | + path: ${{ github.workspace }}/** |
| 56 | + |
| 57 | + stage-release-linux: |
| 58 | + runs-on: ubuntu-latest |
| 59 | + needs: prepare-release |
| 60 | + strategy: |
| 61 | + matrix: |
| 62 | + include: |
| 63 | + - setup: centos6-x86_64 |
| 64 | + docker-compose-build: "-f docker/docker-compose.centos-6.yaml -f docker/docker-compose.centos-6.18.yaml build" |
| 65 | + docker-compose-run: "-f docker/docker-compose.centos-6.yaml -f docker/docker-compose.centos-6.18.yaml run stage-release" |
| 66 | + - setup: debian7-x86_64 |
| 67 | + docker-compose-build: "-f docker/docker-compose.debian.yaml -f docker/docker-compose.debian-7.18.yaml build" |
| 68 | + docker-compose-run: "-f docker/docker-compose.debian.yaml -f docker/docker-compose.debian-7.18.yaml run stage-release" |
| 69 | + - setup: centos7-aarch64 |
| 70 | + docker-compose-build: "-f docker/docker-compose.centos-7.yaml build" |
| 71 | + docker-compose-run: "-f docker/docker-compose.centos-7.yaml run cross-compile-aarch64-stage-release" |
| 72 | + |
| 73 | + name: stage-release-${{ matrix.setup }} |
| 74 | + |
| 75 | + steps: |
| 76 | + - name: Download release-workspace |
| 77 | + uses: actions/download-artifact@v2 |
| 78 | + with: |
| 79 | + name: prepare-release-workspace |
| 80 | + path: ./prepare-release-workspace/ |
| 81 | + |
| 82 | + - name: Set up JDK 8 |
| 83 | + uses: actions/setup-java@v1 |
| 84 | + with: |
| 85 | + java-version: 8 |
| 86 | + |
| 87 | + - name: Setup git configuration |
| 88 | + run: | |
| 89 | + |
| 90 | + git config --global user.name "Netty Project Bot" |
| 91 | +
|
| 92 | + - name: Install SSH key |
| 93 | + uses: shimataro/ssh-key-action@v2 |
| 94 | + with: |
| 95 | + key: ${{ secrets.SSH_PRIVATE_KEY_PEM }} |
| 96 | + known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }} |
| 97 | + |
| 98 | + # Enable caching of Docker layers |
| 99 | + |
| 100 | + env: |
| 101 | + docker-cache-name: staging-${{ matrix.setup }}-cache-docker |
| 102 | + continue-on-error: true |
| 103 | + with: |
| 104 | + key: ${{ runner.os }}-staging-${{ env.docker-cache-name }}-{hash} |
| 105 | + restore-keys: | |
| 106 | + ${{ runner.os }}-staging-${{ env.docker-cache-name }}- |
| 107 | +
|
| 108 | + |
| 109 | + with: |
| 110 | + servers: | |
| 111 | + [{ |
| 112 | + "id": "sonatype-nexus-staging", |
| 113 | + "username": "${{ secrets.SONATYPE_USERNAME }}", |
| 114 | + "password": "${{ secrets.SONATYPE_PASSWORD }}" |
| 115 | + }] |
| 116 | +
|
| 117 | + - name: Create local staging directory |
| 118 | + run: mkdir -p ~/local-staging |
| 119 | + |
| 120 | + - name: Build docker image |
| 121 | + working-directory: ./prepare-release-workspace/ |
| 122 | + run: docker-compose ${{ matrix.docker-compose-build }} |
| 123 | + |
| 124 | + - name: Stage release to local staging directory |
| 125 | + working-directory: ./prepare-release-workspace/ |
| 126 | + env: |
| 127 | + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} |
| 128 | + GPG_KEYNAME: ${{ secrets.GPG_KEYNAME }} |
| 129 | + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 130 | + run: docker-compose ${{ matrix.docker-compose-run }} |
| 131 | + |
| 132 | + - name: Upload local staging directory |
| 133 | + uses: actions/upload-artifact@v2 |
| 134 | + with: |
| 135 | + name: ${{ matrix.setup }}-local-staging |
| 136 | + path: ~/local-staging |
| 137 | + if-no-files-found: error |
| 138 | + |
| 139 | + - name: Rollback release on failure |
| 140 | + working-directory: ./prepare-release-workspace/ |
| 141 | + if: ${{ failure() }} |
| 142 | + # Rollback the release in case of an failure |
| 143 | + run: bash ./.github/scripts/release_rollback.sh release.properties netty/netty-tcnative main |
| 144 | + |
| 145 | + stage-release-windows-x86_64: |
| 146 | + runs-on: windows-2016 |
| 147 | + name: stage-release-windows-x86_64 |
| 148 | + needs: prepare-release |
| 149 | + steps: |
| 150 | + - name: Download release-workspace |
| 151 | + uses: actions/download-artifact@v2 |
| 152 | + with: |
| 153 | + name: prepare-release-workspace |
| 154 | + path: prepare-release-workspace |
| 155 | + |
| 156 | + - name: Setup git configuration |
| 157 | + run: | |
| 158 | + |
| 159 | + git config --global user.name "Netty Project Bot" |
| 160 | +
|
| 161 | + - name: Install SSH key |
| 162 | + uses: shimataro/ssh-key-action@v2 |
| 163 | + with: |
| 164 | + key: ${{ secrets.SSH_PRIVATE_KEY_PEM }} |
| 165 | + known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }} |
| 166 | + |
| 167 | + - name: Set up JDK 8 |
| 168 | + uses: actions/setup-java@v1 |
| 169 | + with: |
| 170 | + java-version: 8 |
| 171 | + |
| 172 | + - name: Add msbuild to PATH |
| 173 | + |
| 174 | + |
| 175 | + - name: Configuring Developer Command Prompt |
| 176 | + uses: ilammy/msvc-dev-cmd@v1 |
| 177 | + with: |
| 178 | + arch: x86_amd64 |
| 179 | + |
| 180 | + - name: Import GPG key |
| 181 | + id: import_gpg |
| 182 | + uses: crazy-max/ghaction-import-gpg@v3 |
| 183 | + with: |
| 184 | + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} |
| 185 | + passphrase: ${{ secrets.GPG_PASSPHRASE }} |
| 186 | + |
| 187 | + - name: Install tools |
| 188 | + uses: crazy-max/ghaction-chocolatey@v1 |
| 189 | + with: |
| 190 | + args: install ninja nasm |
| 191 | + |
| 192 | + # Cache .m2/repository |
| 193 | + - uses: actions/cache@v2 |
| 194 | + env: |
| 195 | + cache-name: staging-release-cache-windows-m2-repository |
| 196 | + with: |
| 197 | + path: ~/.m2/repository |
| 198 | + key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} |
| 199 | + restore-keys: | |
| 200 | + ${{ runner.os }}-${{ env.cache-name }}- |
| 201 | + ${{ runner.os }}- |
| 202 | +
|
| 203 | + |
| 204 | + with: |
| 205 | + servers: | |
| 206 | + [{ |
| 207 | + "id": "sonatype-nexus-staging", |
| 208 | + "username": "${{ secrets.SONATYPE_USERNAME }}", |
| 209 | + "password": "${{ secrets.SONATYPE_PASSWORD }}" |
| 210 | + }] |
| 211 | +
|
| 212 | + - name: Stage release to local staging directory |
| 213 | + working-directory: prepare-release-workspace |
| 214 | + run: mvn --file pom.xml -Pstage -pl boringssl-static clean javadoc:jar package gpg:sign org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DnexusUrl=https://oss.sonatype.org -DserverId=sonatype-nexus-staging -DaltStagingDirectory=local-staging -DskipRemoteStaging=true -DskipTests=true -D'checkstyle.skip=true' |
| 215 | + |
| 216 | + - name: Upload local staging directory |
| 217 | + uses: actions/upload-artifact@v2 |
| 218 | + with: |
| 219 | + name: windows-x86_64-local-staging |
| 220 | + path: prepare-release-workspace/boringssl-static/local-staging |
| 221 | + if-no-files-found: error |
| 222 | + |
| 223 | + - name: Rollback release on failure |
| 224 | + working-directory: prepare-release-workspace |
| 225 | + if: ${{ failure() }} |
| 226 | + # Rollback the release in case of an failure |
| 227 | + run: ./.github/scripts/release_rollback.ps1 release.properties netty/netty-tcnative main |
| 228 | + |
| 229 | + deploy-staged-release: |
| 230 | + runs-on: ubuntu-18.04 |
| 231 | + # Wait until we have staged everything |
| 232 | + needs: [stage-release-linux, stage-release-windows-x86_64] |
| 233 | + steps: |
| 234 | + - name: Download release-workspace |
| 235 | + uses: actions/download-artifact@v2 |
| 236 | + with: |
| 237 | + name: prepare-release-workspace |
| 238 | + path: ./prepare-release-workspace/ |
| 239 | + |
| 240 | + - name: Set up JDK 8 |
| 241 | + uses: actions/setup-java@v1 |
| 242 | + with: |
| 243 | + java-version: 8 |
| 244 | + |
| 245 | + - name: Setup git configuration |
| 246 | + run: | |
| 247 | + |
| 248 | + git config --global user.name "Netty Project Bot" |
| 249 | +
|
| 250 | + - name: Install SSH key |
| 251 | + uses: shimataro/ssh-key-action@v2 |
| 252 | + with: |
| 253 | + key: ${{ secrets.SSH_PRIVATE_KEY_PEM }} |
| 254 | + known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }} |
| 255 | + |
| 256 | + # Hardcode the staging artifacts that need to be downloaded. |
| 257 | + # These must match the matrix setups. There is currently no way to pull this out of the config. |
| 258 | + - name: Download windows-x86_64 staging directory |
| 259 | + uses: actions/download-artifact@v2 |
| 260 | + with: |
| 261 | + name: windows-x86_64-local-staging |
| 262 | + path: ~/windows-x86_64-local-staging |
| 263 | + |
| 264 | + - name: Download centos7-aarch64 staging directory |
| 265 | + uses: actions/download-artifact@v2 |
| 266 | + with: |
| 267 | + name: centos7-aarch64-local-staging |
| 268 | + path: ~/centos7-aarch64-local-staging |
| 269 | + |
| 270 | + - name: Download debian7-x86_64 staging directory |
| 271 | + uses: actions/download-artifact@v2 |
| 272 | + with: |
| 273 | + name: debian7-x86_64-local-staging |
| 274 | + path: ~/debian7-x86_64-local-staging |
| 275 | + |
| 276 | + - name: Download centos6-x86_64 staging directory |
| 277 | + uses: actions/download-artifact@v2 |
| 278 | + with: |
| 279 | + name: centos6-x86_64-local-staging |
| 280 | + path: ~/centos6-x86_64-local-staging |
| 281 | + |
| 282 | + # This step takes care of merging all the previous staged repositories in a way that will allow us to deploy |
| 283 | + # all together with one maven command. |
| 284 | + - name: Merge staging repositories |
| 285 | + working-directory: ./prepare-release-workspace/ |
| 286 | + run: bash ./.github/scripts/merge_local_staging.sh /home/runner/local-staging/staging ~/windows-x86_64-local-staging/staging ~/centos7-aarch64-local-staging/staging ~/debian7-x86_64-local-staging/staging ~/centos6-x86_64-local-staging/staging |
| 287 | + |
| 288 | + |
| 289 | + with: |
| 290 | + servers: | |
| 291 | + [{ |
| 292 | + "id": "sonatype-nexus-staging", |
| 293 | + "username": "${{ secrets.SONATYPE_USERNAME }}", |
| 294 | + "password": "${{ secrets.SONATYPE_PASSWORD }}" |
| 295 | + }] |
| 296 | +
|
| 297 | + - name: Deploy local staged artifacts |
| 298 | + working-directory: ./prepare-release-workspace/ |
| 299 | + # If we don't want to close the repository we can add -DskipStagingRepositoryClose=true |
| 300 | + run: mvn -B --file pom.xml org.sonatype.plugins:nexus-staging-maven-plugin:deploy-staged -DnexusUrl=https://oss.sonatype.org -DserverId=sonatype-nexus-staging -DaltStagingDirectory=/home/runner/local-staging -DskipStagingRepositoryClose=true |
| 301 | + |
| 302 | + - name: Rollback release on failure |
| 303 | + working-directory: ./prepare-release-workspace/ |
| 304 | + if: ${{ failure() }} |
| 305 | + # Rollback the release in case of an failure |
| 306 | + run: bash ./.github/scripts/release_rollback.sh release.properties netty/netty-tcnative main |