Skip to content

Commit

Permalink
ci: release management implemented (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
srtvprateek committed Jun 1, 2023
1 parent 743e678 commit 1edc7e1
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 9 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/process_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Release Workflow
on:
release:
types:
- created

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Run on New Release
run: |
echo "A new release was created."
echo "Release name: ${{ github.event.release.name }}"
echo "Release tag: ${{ github.event.release.tag_name }}"
- name: Validating Release
run: |
pattern="^v[0-9]+(\.[0-9]+)+$"
if [[ ${{ github.event.release.name }} =~ $pattern ]]; then
echo "${{ github.event.release.name }} is valid"
else
echo "${{ github.event.release.name }} is not valid"
exit 1
fi
- name: Extract Version details
run: |
releaseName="${{ github.event.release.name }}"
echo "release name: $releaseName"
versionName=${releaseName:1}
echo "version name: $versionName"
IFS='.' read -ra versionStubs <<< "$versionName"
echo "versionMajor : ${versionStubs[0]}"
echo "versionMinor : ${versionStubs[1]}"
echo "versionPatch : ${versionStubs[2]}"
echo "versionMajor=${versionStubs[0]}" >> $GITHUB_ENV
echo "versionMinor=${versionStubs[1]}" >> $GITHUB_ENV
echo "versionPatch=${versionStubs[2]}" >> $GITHUB_ENV
- name: Commit version.properties changes
run: |
git fetch --all
git checkout develop
echo "major=${{ env.versionMajor }}" > version.properties
echo "minor=${{ env.versionMinor }}" >> version.properties
echo "patch=${{ env.versionPatch }}" >> version.properties
echo "channel=release" >> version.properties
echo "build=0" >> version.properties
git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --local user.name "${GITHUB_ACTOR}"
git add version.properties
commitTitle="ci(release): version bump ${{ env.versionMajor }}.${{ env.versionMinor }}.${{ env.versionPatch }}"
commitBody="see release details https://github.com/androidPluto/pluto/releases/tag/${{ github.event.release.tag_name }}"
git commit -m "$commitTitle" -m "$commitBody"
- name: Publish artifacts to MavenCentral
# run: ./gradlew publish
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}

- name: Pushing changes to version.properties post deployment
run: |
git fetch --all
git checkout develop
git push
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
.externalNativeBuild
.cxx
/.idea/*
/scripts/publish/publish.properties
11 changes: 6 additions & 5 deletions scripts/publish/module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ afterEvaluate {
}
}

ext["signing.keyId"] = rootProject.ext["signing.keyId"]
ext["signing.password"] = rootProject.ext["signing.password"]
ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"]

signing {
useInMemoryPgpKeys(
rootProject.ext["signing.keyId"],
rootProject.ext["signing.key"],
rootProject.ext["signing.password"]
)
sign publishing.publications
}
}
8 changes: 4 additions & 4 deletions scripts/publish/root.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Create variables with empty default values
ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.secretKeyRingFile"] = ''
ext["signing.key"] = ''
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
ext["sonatypeStagingProfileId"] = ''

// reading values from local.properties
File secretPropsFile = project.rootProject.file('local.properties')
File secretPropsFile = project.rootProject.file("$rootDir/scripts/publish/publish.properties")
if (secretPropsFile.exists()) {
// Read local.properties file first if it exists
Properties p = new Properties()
Expand All @@ -20,7 +20,7 @@ if (secretPropsFile.exists()) {
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
ext["signing.key"] = System.getenv('SIGNING_SECRET_KEY')
}

// Set up Sonatype repository
Expand All @@ -35,4 +35,4 @@ nexusPublishing {
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
}

0 comments on commit 1edc7e1

Please sign in to comment.