Release provider libraries (#807) #653
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Prepare release | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
tag: | |
name: Tag release | |
runs-on: ubuntu-latest | |
outputs: | |
is_release: ${{ steps.check-number-of-tags.outputs.is_release }} | |
steps: | |
- name: Check out project sources | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Set up Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: adopt | |
java-version: 21 | |
- name: Set up Git user | |
run: | | |
git config --global user.name "pulumi-kotlin[bot]" | |
git config --global user.email "138587440+pulumi-kotlin[bot]@users.noreply.github.com" | |
- name: Tag new versions of Pulumi Kotlin (if available) | |
run: ./gradlew tagRecentRelease | |
- name: Check number of tags | |
id: check-number-of-tags | |
run: | | |
number_of_tags=$(git tag --points-at HEAD | wc -l | awk '{print $1}') | |
if [[ "$number_of_tags" == "0" ]]; then is_release=false; else is_release=true; fi | |
echo "is_release=$is_release" >> $GITHUB_OUTPUT | |
- name: Push tags | |
run: git push --tags | |
publish: | |
name: Publish pulumi-${{ matrix.provider }}-kotlin (${{ matrix.major-version }}) to Maven Central Repository | |
needs: tag | |
runs-on: ${{ matrix.runs-on }} | |
if: ${{ needs.tag.outputs.is_release == 'true' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- provider: cloudflare | |
major-version: 5 | |
runs-on: [ ubuntu-latest ] | |
- provider: slack | |
major-version: 0 | |
runs-on: [ ubuntu-latest ] | |
- provider: github | |
major-version: 6 | |
runs-on: [ ubuntu-latest ] | |
- provider: random | |
major-version: 4 | |
runs-on: [ ubuntu-latest ] | |
- provider: gcp | |
major-version: 8 | |
runs-on: [ self-hosted, active ] | |
- provider: google-native | |
major-version: 0 | |
runs-on: [ self-hosted, active ] | |
- provider: aws | |
major-version: 6 | |
runs-on: [ self-hosted, active ] | |
- provider: aws-native | |
major-version: 1 | |
runs-on: [ self-hosted, active ] | |
- provider: azure | |
major-version: 6 | |
runs-on: [ self-hosted, active ] | |
- provider: azure-native | |
major-version: 2 | |
runs-on: [ self-hosted, active ] | |
- provider: kubernetes | |
major-version: 4 | |
runs-on: [ self-hosted, active ] | |
- provider: nomad | |
major-version: 2 | |
runs-on: [ ubuntu-latest ] | |
- provider: docker | |
major-version: 4 | |
runs-on: [ ubuntu-latest ] | |
- provider: gitlab | |
major-version: 8 | |
runs-on: [ ubuntu-latest ] | |
- provider: digitalocean | |
major-version: 4 | |
runs-on: [ ubuntu-latest ] | |
- provider: alicloud | |
major-version: 3 | |
runs-on: [ self-hosted, active ] | |
- provider: keycloak | |
major-version: 5 | |
runs-on: [ ubuntu-latest ] | |
- provider: vault | |
major-version: 6 | |
runs-on: [ ubuntu-latest ] | |
steps: | |
- id: provider | |
uses: ASzc/change-string-case-action@v6 | |
with: | |
string: ${{ matrix.provider }} | |
- name: Check out project sources | |
uses: actions/checkout@v4 | |
- name: Set up Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: adopt | |
java-version: 21 | |
- name: Check if publication to Maven Central is necessary | |
id: check-for-release | |
shell: python | |
run: | | |
import os | |
import json | |
with open("src/main/resources/version-config.json") as version_config: | |
schemas = json.load(version_config) | |
versions = [ | |
schema["kotlinVersion"] for schema in schemas | |
if schema["providerName"] == "${{ matrix.provider }}" | |
and schema["kotlinVersion"].split(".")[0] == "${{ matrix.major-version }}" | |
] | |
version = versions[0] | |
is_release = not version.endswith("-SNAPSHOT") | |
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh: | |
fh.write('is_release=' + str(is_release).lower()) | |
- name: Set up Java | |
if: ${{ steps.check-for-release.outputs.is_release == 'true' }} | |
uses: actions/setup-java@v4 | |
with: | |
distribution: adopt | |
java-version: 21 | |
- name: Publish packages | |
id: publish-to-maven-central | |
if: ${{ steps.check-for-release.outputs.is_release == 'true' }} | |
run: | | |
./gradlew publishPulumi${{ matrix.provider }}${{ matrix.major-version }}PublicationToMavenCentralRepository \ | |
-Psigning.enabled=true \ | |
-Psigning.key="${{ secrets.GPG_KEY }}" \ | |
-Psigning.key.password="${{ secrets.GPG_KEY_PASSWORD }}" \ | |
-Psonatype.username="${{ secrets.SONATYPE_USERNAME }}" \ | |
-Psonatype.password="${{ secrets.SONATYPE_PASSWORD }}" \ | |
-Dorg.gradle.jvmargs="-Xmx50g -Xss2048k" \ | |
-Dorg.gradle.workers.max=1 \ | |
-Dorg.gradle.daemon=false \ | |
-Pkotlin.compiler.execution.strategy=in-process \ | |
-q | |
- name: Rename Dokka directory before upload | |
if: ${{ steps.check-for-release.outputs.is_release == 'true' }} | |
run: | | |
file_name=$(ls ./build/libs/pulumi-${{ matrix.provider }}-kotlin-${{ matrix.major-version }}*-javadoc.jar | xargs -n 1 basename) | |
version=$(echo $file_name | sed -e "s/^pulumi-${{ matrix.provider }}-kotlin-//" -e "s/-javadoc.jar$//") | |
mkdir -p ./docs/${{ matrix.provider }}/$version | |
mv ./build/dokka/pulumi${{ steps.provider.outputs.capitalized }}${{ matrix.major-version }}Javadoc/* ./docs/${{ matrix.provider }}/$version | |
- name: Install GitHub CLI # TODO: move this step to runner VM setup | |
if: ${{ steps.check-for-release.outputs.is_release == 'true' && !contains(matrix.runs-on, 'ubuntu-latest') }} | |
uses: dev-hanz-ops/[email protected] | |
- name: Install missing tools # TODO: move this step to runner VM setup | |
if: ${{ steps.check-for-release.outputs.is_release == 'true' && !contains(matrix.runs-on, 'ubuntu-latest') }} | |
run: yum -y install wget zip | |
- name: Install Rclone | |
if: ${{ steps.check-for-release.outputs.is_release == 'true' }} | |
uses: AnimMouse/setup-rclone@v1 | |
- name: Configure Rclone | |
if: ${{ steps.check-for-release.outputs.is_release == 'true' }} | |
run: | | |
mkdir -p ~/.config/rclone | |
cp .github/workflows/rclone.conf ~/.config/rclone/rclone.conf | |
echo "$GCP_SERVICE_ACCOUNT_FILE" > ~/.config/gcp-key.json | |
env: | |
# pulumi-kotlin-docs service account key created manually through GCP UI and added manually to GitHub by @myhau (Michal Fudala) | |
GCP_SERVICE_ACCOUNT_FILE: ${{ secrets.GCP_SERVICE_ACCOUNT_FILE }} | |
- name: Upload Dokka artifacts | |
if: ${{ steps.check-for-release.outputs.is_release == 'true' }} | |
run: | | |
rclone copy --transfers=1024 ./docs/${{ matrix.provider }} rclone-jvm-lab:/pulumi-kotlin-docs/${{ matrix.provider }} | |
- name: Upload buildSrc test report | |
if: ${{ failure() && steps.publish-to-maven-central.outcome == 'failure' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-src-test-report | |
path: ./buildSrc/build/reports/tests/test/* | |
retention-days: 3 | |
cleanup: | |
name: Clean up after release | |
needs: tag | |
runs-on: ubuntu-latest | |
if: ${{ needs.tag.outputs.is_release == 'true' }} | |
steps: | |
- name: Check out project sources | |
uses: actions/checkout@v4 | |
- name: Set up Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: adopt | |
java-version: 21 | |
- name: Set up Git user | |
run: | | |
git config --global user.name "pulumi-kotlin[bot]" | |
git config --global user.email "138587440+pulumi-kotlin[bot]@users.noreply.github.com" | |
- name: Prepare for next development phase | |
run: ./gradlew postRelease | |
- uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0 | |
id: generate-token | |
with: | |
app_id: ${{ secrets.APP_ID }} | |
private_key: ${{ secrets.APP_PRIVATE_KEY }} | |
- name: Create pull request | |
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5 | |
with: | |
title: Prepare for next development phase | |
body: | | |
## Task | |
Resolves: None | |
## Description | |
This PR was triggered automatically after a release. It replaces the released versions with SNAPSHOT versions. | |
base: main | |
branch: prepare-for-next-development-phase | |
token: ${{ steps.generate-token.outputs.token }} |