Production Release With Version #125
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: Production Release With Version | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "Version (optional)" | |
required: false | |
default: "" | |
confirm: | |
type: boolean | |
required: true | |
default: false | |
description: Yes, I want to release. | |
is-production: | |
type: boolean | |
required: true | |
default: true | |
description: "release to production saas" | |
is-self-hosted: | |
type: boolean | |
required: true | |
default: true | |
description: "release to self hosted" | |
jobs: | |
confirm: | |
name: Confirm publish | |
runs-on: ubuntu-latest | |
steps: | |
- name: Confirm | |
if: ${{ github.event.inputs.confirm != 'true' }} | |
run: | | |
echo "Please confirm that you want to release" | |
exit 1 | |
set-version: | |
name: Set version | |
runs-on: ubuntu-latest | |
outputs: | |
build_version: ${{ steps.get_build_version.outputs.build_version }} | |
needs: | |
- confirm | |
steps: | |
- name: ⇣ Checkout | |
uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.GH_BUILDER_TOKEN }} | |
- uses: actions/setup-java@v1 | |
with: | |
java-version: 11 | |
- name: Set version | |
run: | | |
set -e | |
OLD_VERSION="$(./gradlew -q :Tabnine:currentVersion)" | |
NEW_VERSION="${{ github.event.inputs.version }}" | |
if [ -z "$NEW_VERSION" ]; then | |
OLD_MAJOR=$(echo $OLD_VERSION | cut -d. -f1) | |
OLD_MINOR=$(echo $OLD_VERSION | cut -d. -f2) | |
OLD_PATCH=$(echo $OLD_VERSION | cut -d. -f3) | |
NEW_MINOR=$((OLD_MINOR + 1)) | |
NEW_VERSION=$OLD_MAJOR.$NEW_MINOR.0 | |
fi | |
sed -i "s/project\.externalVersion : '.*\..*\..*'/project\.externalVersion : '$NEW_VERSION'/g" Tabnine/build.gradle | |
sed -i "s/project\.externalVersion : '.*\..*\..*'/project\.externalVersion : '$NEW_VERSION'/g" TabnineSelfHosted/build.gradle | |
- name: Get Version | |
id: get_build_version | |
run: | | |
VERSION="$(./gradlew -q :Tabnine:currentVersion)" | |
echo "new version is $VERSION" | |
echo "build_version=$VERSION" >> $GITHUB_OUTPUT | |
- name: Setup git | |
run: | | |
set -ex | |
git config --global user.email "[email protected]" | |
git config --global user.name "codota-builder" | |
- name: Commit changes | |
run: | | |
NEW_VERSION="${{ steps.get_build_version.outputs.build_version }}" | |
git commit -am "Set version to $NEW_VERSION" | |
git push | |
git tag v$NEW_VERSION | |
git push origin v$NEW_VERSION | |
publish-production: | |
if: ${{ github.event.inputs.is-production == 'true' }} | |
name: Publish to PRODUCTION | |
runs-on: ubuntu-latest | |
needs: | |
- set-version | |
steps: | |
- name: ⇣ Checkout | |
uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.GH_BUILDER_TOKEN }} | |
- uses: actions/setup-java@v1 | |
with: | |
java-version: 11 | |
- uses: actions/cache@v2 | |
name: Cache Gradle packages | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: ${{ runner.os }}-gradle | |
- name: Get Chat Version | |
id: get_chat_version | |
run: echo "version=$(cat ./.chatversion)" >> $GITHUB_ENV | |
- name: Checkout Chat Application Repository | |
uses: dsaltares/fetch-gh-release-asset@master | |
with: | |
repo: "codota/tabnine-chat-app" | |
version: "tags/${{ env.version }}" | |
file: "build.tar.gz" | |
token: ${{ secrets.gh_builder_token }} | |
- name: Extract Chat App Build | |
run: | | |
mkdir -p ./Tabnine/tabnineChat | |
cp build.tar.gz ./Tabnine/tabnineChat/chat-bundle.tar.gz | |
- name: Publish production plugin | |
run: | | |
./gradlew :Tabnine:publishPlugin -PexternalVersion=${{ needs.set-version.outputs.build_version }} -Pchannel=production | |
env: | |
HUB_TOKEN: ${{ secrets.HUB_TOKEN }} | |
- name: Get Plugin Path | |
id: get_plugin_path | |
run: echo "plugin_path=$(ls -t Tabnine/build/distributions/TabNine-*.zip | head -1)" >> $GITHUB_OUTPUT | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ needs.set-version.outputs.build_version }} | |
release_name: v${{ needs.set-version.outputs.build_version }} | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ steps.get_plugin_path.outputs.plugin_path }} | |
asset_name: TabNine.zip | |
asset_content_type: application/zip | |
- name: Send Slack release message | |
if: success() | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_RELEASES_CHANNEL_WEBHOOK_URL }} | |
SLACK_CHANNEL: releases-automation | |
SLACK_TITLE: "intellij ${{ needs.set-version.outputs.build_version }} version released to production" | |
SLACK_USERNAME: "intellij update" | |
SLACK_ICON_EMOJI: ":intellij:" | |
SLACK_MESSAGE: ${{ github.event.head_commit.message }} | |
SLACK_FOOTER: " " | |
publish-self-hosted: | |
if: ${{ github.event.inputs.is-self-hosted == 'true' }} | |
name: Publish self hosted | |
runs-on: ubuntu-latest | |
needs: | |
- set-version | |
steps: | |
- name: ⇣ Checkout | |
uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.GH_BUILDER_TOKEN }} | |
- uses: actions/setup-java@v1 | |
with: | |
java-version: 11 | |
- uses: actions/cache@v2 | |
name: Cache Gradle packages | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: ${{ runner.os }}-gradle | |
- name: Get Chat Version | |
id: get_chat_version | |
run: echo "version=$(cat ./.chatversion)" >> $GITHUB_ENV | |
- name: Checkout Chat Application Repository | |
uses: dsaltares/fetch-gh-release-asset@master | |
with: | |
repo: "codota/tabnine-chat-app" | |
version: "tags/${{ env.version }}" | |
file: "build.tar.gz" | |
token: ${{ secrets.gh_builder_token }} | |
- name: Extract Chat App Build | |
run: | | |
mkdir -p ./TabnineSelfHosted/tabnineChat | |
cp build.tar.gz ./TabnineSelfHosted/tabnineChat/chat-bundle.tar.gz | |
- name: Build the self-hosted plugin | |
run: ./gradlew :TabnineSelfHosted:buildPlugin -PexternalVersion=${{ needs.set-version.outputs.build_version }} -Pchannel=self_hosted | |
- name: Get Plugin Path | |
id: get_plugin_path | |
run: echo "plugin_path=$(ls -t TabnineSelfHosted/build/distributions/TabNine*.zip | head -1)" >> $GITHUB_OUTPUT | |
- name: Set stable version file | |
run: | | |
echo ${{ needs.set-version.outputs.build_version }} > stable | |
- name: Authenticate to Google Cloud | |
uses: "google-github-actions/auth@v1" | |
with: | |
credentials_json: ${{ secrets.GCS_RELEASE_KEY }} | |
- name: ⬆️ Upload latest stable version to GCS | |
uses: google-github-actions/upload-cloud-storage@v1 | |
with: | |
path: stable | |
destination: tabnine-self-hosted-artifacts/jetbrains | |
parent: false | |
gzip: false | |
headers: |- | |
content-type: text/plain | |
- name: ⬆️ Upload zip to GCS | |
uses: google-github-actions/upload-cloud-storage@v1 | |
with: | |
path: ${{ steps.get_plugin_path.outputs.plugin_path }} | |
destination: tabnine-self-hosted-artifacts/jetbrains | |
parent: false |