Skip to content

Commit

Permalink
ci: add release workflow (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
falconandy authored Jun 20, 2023
1 parent 5ae0c51 commit 42e0261
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Release

on:
workflow_dispatch:
inputs:
dryRun:
description: 'Do a dry run to preview instead of a real release'
required: true
default: 'true'

jobs:
authorize:
name: Authorize
runs-on: ubuntu-latest
steps:
- name: ${{ github.actor }} permission check to do a release
uses: "lannonbr/[email protected]"
with:
permission: "write"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release:
name: Release
runs-on: ubuntu-latest
needs: [authorize]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'zulu'

- name: Build
run: ./gradlew build

- name: Test
run: ./gradlew test --info

- name: Configure GPG
run: |
echo '${{ secrets.GPG_KEY_CONTENTS }}' | base64 -d > 'secring.gpg'
- name: Semantic Release --dry-run
if: ${{ github.event.inputs.dryRun == 'true'}}
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: |
npx \
-p lodash \
-p semantic-release@17 \
-p @semantic-release/changelog@5 \
-p @semantic-release/git@9 \
-p @google/semantic-release-replace-plugin@1 \
-p @semantic-release/exec@5 \
semantic-release --dry-run
- name: Semantic Release
if: ${{ github.event.inputs.dryRun == 'false'}}
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]
SECURE_REPO_USER: ${{ secrets.OSSRH_USERNAME }}
SECURE_REPO_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_SECRET_RING_FILE: ../../secring.gpg
run: |
npx \
-p lodash \
-p semantic-release@17 \
-p @semantic-release/changelog@5 \
-p @semantic-release/git@9 \
-p @google/semantic-release-replace-plugin@1 \
-p @semantic-release/exec@5 \
semantic-release
Empty file added CHANGELOG.md
Empty file.
69 changes: 69 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
module.exports = {
"branches": [
{name: 'beta', prerelease: true},
"main"
],
"tagFormat": ["v${version}"],
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "angular",
"parserOpts": {
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
}
}],
["@semantic-release/release-notes-generator", {
"preset": "angular",
}],
["@semantic-release/changelog", {
"changelogFile": "CHANGELOG.md"
}],
"@semantic-release/github",
[
"@google/semantic-release-replace-plugin",
{
"replacements": [
{
"files": ["gradle.properties"],
"from": "ARTIFACT_VERSION=.*",
"to": "ARTIFACT_VERSION=${nextRelease.version}",
"results": [
{
"file": "gradle.properties",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}
],
"countMatches": true
},
{
"files": ["src/main/java/com/amplitude/Constants.java"],
"from": "String SDK_VERSION = \".*\";",
"to": "String SDK_VERSION = \"${nextRelease.version}\";",
"results": [
{
"file": "src/main/java/com/amplitude/Constants.java",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}
],
"countMatches": true
},
]
}
],
["@semantic-release/git", {
"assets": ["gradle.properties", "CHANGELOG.md", "src/main/java/com/amplitude/Constants.java"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}],
["@semantic-release/exec", {
"publishCmd": `./gradlew publishMavenJavaPublicationToMySecureRepository \
-PmySecureRepositoryUsername="$SECURE_REPO_USER" \
-PmySecureRepositoryPassword="$SECURE_REPO_PASSWORD" \
-Psigning.keyId="$SIGNING_KEY_ID" \
-Psigning.password="$SIGNING_PASSWORD" \
-Psigning.secretKeyRingFile="$SIGNING_SECRET_RING_FILE"`,
}],
],
}

0 comments on commit 42e0261

Please sign in to comment.