Skip to content

Commit

Permalink
feat: add in semantic release work
Browse files Browse the repository at this point in the history
  • Loading branch information
mchuangatmp committed Jun 28, 2021
1 parent de1f552 commit 8e26f79
Show file tree
Hide file tree
Showing 7 changed files with 281 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cross-platform-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Cross Platform Tests
on:
pull_request
jobs:
run-android-tests:
cross-platform-tests:
timeout-minutes: 30
runs-on: macos-11
steps:
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/pr-title-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Semantic PR Check
on:
pull_request:
types: [opened, synchronize, edited]
jobs:
pr-title-check:
name: Check PR for semantic title
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-18.04
steps:
- name: Set PR title validity
id: is-semantic
if: >
startsWith(github.event.pull_request.title, 'feat:')||
startsWith(github.event.pull_request.title, 'fix:') ||
startsWith(github.event.pull_request.title, 'perf:') ||
startsWith(github.event.pull_request.title, 'docs:') ||
startsWith(github.event.pull_request.title, 'test:') ||
startsWith(github.event.pull_request.title, 'refactor:') ||
startsWith(github.event.pull_request.title, 'style:') ||
startsWith(github.event.pull_request.title, 'build:') ||
startsWith(github.event.pull_request.title, 'ci:') ||
startsWith(github.event.pull_request.title, 'chore:') ||
startsWith(github.event.pull_request.title, 'revert:')
run: |
OUTPUT=true
echo "::set-output name=isSemantic::$OUTPUT"
- name: echo isSemantic
run: |
echo ${{ steps.is-semantic.outputs.isSemantic }}
- name: PR title is valid
if: ${{steps.is-semantic.outputs.isSemantic == 'true'}}
run: |
echo 'Pull request title is valid.'
echo ${{ steps.is-semantic.outputs.isSemantic }}
- name: PR title is invalid
if: ${{ steps.is-semantic.outputs.isSemantic != 'true'}}
run: |
echo ${{ steps.is-semantic.outputs.isSemantic }}
echo 'Pull request title is not valid.'
exit 1
6 changes: 3 additions & 3 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Android SDK build and test
name: Build and Test
on: [push, pull_request]
jobs:
instrumented-tests:
Expand All @@ -20,7 +20,7 @@ jobs:
path: android-core/build/reports/androidTests/connected/**
unit-tests:
timeout-minutes: 15
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
steps:
- name: Checkout Branch
uses: actions/checkout@v2
Expand All @@ -36,7 +36,7 @@ jobs:

automerge:
name: Rebase dependabot PRs
runs-on: [ubuntu-latest]
runs-on: ubuntu-18.04
needs: [instrumented-tests, unit-tests]
if: contains(github.repository, 'internal') && github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'
steps:
Expand Down
185 changes: 185 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
name: "Release SDK"

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

jobs:
# SDK release is done from public/master branch.
confirm-master-branch:
name: "Confirm release is run on master branch"
runs-on: ubuntu-18.04
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Branch name
run: |
BRANCHNAME=${GITHUB_REF##*/}
echo "pulling branch name, branch name is:"
echo $BRANCHNAME
if [ $BRANCHNAME != "master" ]
then
echo "You can only run a release from the master branch, you are trying to run it from ${BRANCHNAME}"
exit 1
fi
instrumented-tests:
timeout-minutes: 30
needs: confirm-master-branch
runs-on: macos-11
steps:
- name: "Checkout Internal Development Branch"
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: mparticle/mparticle-android-sdk-internal
token: ${{ secrets.ANDROID_SDK_PAT }}
ref: development
- name: "Run Instrumented Tests"
uses: reactivecircus/[email protected]
with:
api-level: 29
script: ./gradlew :android-core:cAT :android-kit-base:cAT --stacktrace
- name: "Archive Instrumented Test Results"
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: test-results
path: android-core/build/reports/androidTests/connected/**
unit-tests:
timeout-minutes: 15
needs: confirm-master-branch
runs-on: ubuntu-18.04
steps:
- name: "Checkout Internal Development Branch"
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: mparticle/mparticle-android-sdk-internal
token: ${{ secrets.ANDROID_SDK_PAT }}
ref: development
- name: Install JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Run Unit Tests
run: ./gradlew test
- name: Android Test Report
uses: asadmansr/[email protected]
if: ${{ always() }}
update-kits:
needs: [instrumented-tests, unit-tests]
runs-on: macos-11
env:
GIT_AUTHOR_NAME: mparticle-bot
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: mparticle-bot
GIT_COMMITTER_EMAIL: [email protected]
steps:
- name: "Checkout Internal Development Branch"
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: mparticle/mparticle-android-sdk-internal
token: ${{ secrets.ANDROID_SDK_PAT }}
ref: development
submodules: recursive
- name: "Build Android Core"
run: ./gradlew -Ptarget_maven_repo=test -PisRelease=true cleanBuildCache clean testRelease uploadArchives
- name: "Update Kit references"
run: git submodule foreach "git fetch; git reset --hard origin/master";
- name: "Test Kits"
run: ./gradlew -Ptarget_maven_repo=test -PisRelease=true cleanBuildCache clean testRelease uploadArchives -c settings-kits.gradle
- name: "Commit Kit Updates"
run: git add .; git diff-index --quiet HEAD || git commit -m 'Update Submodules'
# - name: "Upload kit branch"
# run: git push origin HEAD:release/${GITHUB_RUN_ID}
semantic-release:
needs: update-kits
runs-on: ubuntu-18.04
env:
GITHUB_TOKEN: ${{ secrets.ANDROID_SDK_PAT }}
GIT_AUTHOR_NAME: mparticle-bot
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: mparticle-bot
GIT_COMMITTER_EMAIL: [email protected]
steps:
- name: "Checkout public/master Branch"
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: ${{ github.repository }}
token: ${{ secrets.ANDROID_SDK_PAT }}
ref: master
- name: "Add new internal/development branch commits to public/master for release"
run: |
git remote add internal https://${{ secrets.ANDROID_SDK_PAT }}@github.com/mParticle/mparticle-android-sdk-internal.git
git fetch internal
git pull internal development
- name: "Semantic Release --dry-run"
if: ${{ github.event.inputs.dryRun == 'true'}}
env:
GITHUB_TOKEN: ${{ secrets.ANDROID_SDK_PAT }}
GIT_AUTHOR_NAME: mparticle-bot
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: mparticle-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 @semantic-release/exec@5 \
semantic-release --dry-run
- name: "Semantic Release"
if: ${{ github.event.inputs.dryRun == 'false'}}
env:
GITHUB_TOKEN: ${{ secrets.ANDROID_SDK_PAT }}
GIT_AUTHOR_NAME: mparticle-bot
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: mparticle-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 @semantic-release/exec@5 \
semantic-release
- name: "Merge back release commits to public/master repository"
if: ${{ github.event.inputs.dryRun == 'false'}}
run: |
git push origin HEAD:master
- name: "Merge back release commits to internal/development repository"
if: ${{ github.event.inputs.dryRun == 'false'}}
run: |
git push internal HEAD:development
git push internal HEAD:master
# - name: "Publish Core to Maven"
# if: ${{ github.event.inputs.dryRun == 'false'}}
# env:
# MAVEN_KEY: ${{ secrets.MAVEN_KEY }}
# MAVEN_SECRET: ${{ secrets.MAVEN_SECRET }}
# SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
# SIGNING_KEY_RING_FILE: ${{ secrets.SIGNING_KEY_RING_FILE }}
# SIGNING_KEY_RING_PASSWORD: ${{ secrets.SIGNING_KEY_RING_PASSWORD }}
# run: |
# ./gradlew cleanBuildCache clean test
# ./gradlew uploadArchives -Ptarget_maven_repo=sonatype -PisRelease=true
# - name: "Publish Kits to Maven"
# if: ${{ github.event.inputs.dryRun == 'false'}}
# env:
# MAVEN_KEY: ${{ secrets.MAVEN_KEY }}
# MAVEN_SECRET: ${{ secrets.MAVEN_SECRET }}
# SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
# SIGNING_KEY_RING_FILE: ${{ secrets.SIGNING_KEY_RING_FILE }}
# SIGNING_KEY_RING_PASSWORD: ${{ secrets.SIGNING_KEY_RING_PASSWORD }}
# run: |
# ./gradlew cleanBuildCache clean test
# ./gradlew uploadArchives -c settings-kits.gradle -Ptarget_maven_repo=sonatype -PisRelease=true
39 changes: 39 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
branches: ["master"],
tagFormat: "v${version}",
plugins: [
[
"@semantic-release/commit-analyzer",
{
preset: "angular",
},
],
[
"@semantic-release/release-notes-generator",
{
preset: "angular",
},
],
[
"@semantic-release/changelog",
{
changelogFile: "CHANGELOG.md",
},
],
[
"@semantic-release/exec",
{
prepareCmd: "sh ./scripts/release.sh ${nextRelease.version}",
},
],
// ["@semantic-release/github"],
[
"@semantic-release/git",
{
assets: ["CHANGELOG.md", "build.gradle", "README.md"],
message:
"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
},
],
],
};
2 changes: 1 addition & 1 deletion scripts/maven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if (target_maven_repo in ['sonatype', 'sonatype-snapshot']) {



uploadArchives{
uploadArchives {
repositories {
mavenDeployer {
if (target_maven_repo == 'sonatype') {
Expand Down
16 changes: 8 additions & 8 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ sed -i '.bak' "s/'com.mparticle:android-another-kit:.*'/'com.mparticle:android-a
#commit the version bump, tag, and push to private and public
git add build.gradle
git add README.md
git commit -m "Update version to $1"
git tag "v$1"
git push origin "v$1"
git remote add public [email protected]:mParticle/mparticle-android-sdk.git
git push public "v$1"
git push origin HEAD:development
git push origin HEAD:master
git push public HEAD:master
# git commit -m "Update version to $1"
# git tag "v$1"
# git push origin "v$1"
# git remote add public [email protected]:mParticle/mparticle-android-sdk.git
# git push public "v$1"
# git push origin HEAD:development
# git push origin HEAD:master
# git push public HEAD:master

0 comments on commit 8e26f79

Please sign in to comment.