Release #11
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: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
required: true | |
type: string | |
description: Release Version (no 'v' prefix) | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
steps: | |
# SETUP & VALIDATION | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Java 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
cache: gradle | |
- name: Validate Release Version | |
if: ${{ startsWith(github.event.inputs.version, 'v') }} | |
uses: actions/github-script@v3 | |
with: | |
script: | | |
core.setFailed('Version ${{ github.event.inputs.version }} must not start with \'v\'. Use a non-prefixed semantic version, e.g. 1.2.3') | |
- name: Lint | |
run: ./gradlew ktlintCheck | |
- name: Clean | |
run: ./gradlew clean | |
- name: Build | |
run: ./gradlew assemble | |
- name: Test | |
run: ./gradlew test --info | |
# SET VERSIONS | |
- name: Set Version (Gradle) | |
uses: jacobtomlinson/gha-find-replace@v2 | |
with: | |
find: 'version = ".*"' | |
replace: 'version = "${{ github.event.inputs.version }}"' | |
include: 'core/build.gradle.kts' | |
regex: true | |
- name: Set Version (Const) | |
uses: jacobtomlinson/gha-find-replace@v2 | |
with: | |
find: 'const val VERSION = ".*"' | |
replace: 'const val VERSION = "${{ github.event.inputs.version }}"' | |
include: 'core/src/main/kotlin/EvaluationProxy.kt' | |
regex: true | |
# RELEASE CORE PACKAGE | |
- name: Release evaluation-proxy-core ${{ github.event.inputs.version }} | |
env: | |
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} | |
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} | |
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} | |
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} | |
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} | |
SIGNING_KEY: ${{ secrets.SIGNING_KEY }} | |
run: | | |
./gradlew core:publishCorePublicationToSonatypeRepository | |
# RELEASE DOCKER IMAGE | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Get Build Date | |
run: | | |
echo "BUILD_DATE=$( date -u +'%Y-%m-%dT%H:%M:%SZ' )" >> $GITHUB_ENV | |
- name: Docker Metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
tags: type=semver,pattern={{version}},value=v${{ github.event.inputs.version }} | |
images: ${{ secrets.DOCKERHUB_USERNAME }}/evaluation-proxy | |
- name: Docker Build and Push | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
build-args: BUILD_DATE=${{ env.BUILD_DATE }} | |
tags: ${{ steps.meta.outputs.tags }} | |
# COMMIT RELEASE | |
- name: Commit Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GIT_AUTHOR_NAME: amplitude-sdk-bot | |
GIT_AUTHOR_EMAIL: [email protected] | |
GIT_COMMITTER_NAME: amplitude-sdk-bot | |
GIT_COMMITTER_EMAIL: [email protected] | |
run: | | |
git commit -am "release: ${{ github.event.inputs.version }}" | |
git tag v${{ github.event.inputs.version }} | |
git push | |
git push --tags |