Skip to content

Release Workflow

Release Workflow #11

Workflow file for this run

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