Merge pull request #4 from estivensh/develop #4
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: Publish Artifacts | |
on: | |
push: | |
branches: [ "main" ] | |
jobs: | |
build: | |
name: Build | |
runs-on: macos-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
- run: ./gradlew incrementPatch | |
name: Increment Version | |
- name: Save version to file | |
run: | | |
version=$(./gradlew printVersion | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9]+)?') | |
echo $version > version.txt | |
- name: Upload version artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: version | |
path: version.txt | |
- name: GIT commit and push all changed files | |
id: version | |
env: | |
CI_COMMIT_MESSAGE: Continuous Integration Build Artifacts | |
CI_COMMIT_AUTHOR: Continuous Integration | |
run: | | |
version=$(cat version.txt) | |
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}" | |
git config --global user.email "[email protected]" | |
git fetch origin | |
git checkout ${{ github.head_ref }} | |
git add . | |
git commit -m "Changed project version to $version" | |
git pull origin ${{ github.head_ref }} | |
git push origin ${{ github.head_ref }} | |
echo "VERSION_NUMBER=$version" >> $GITHUB_OUTPUT | |
- name: Install GPG | |
env: | |
SIGNING_KEY: ${{ secrets.SIGNING_KEY }} | |
run: | | |
echo "$SIGNING_KEY" | gpg --dearmor > ${HOME}/secring.gpg | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Add Gradle Properties | |
env: | |
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | |
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} | |
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} | |
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} | |
run: | | |
echo "mavenCentralUsername=${MAVEN_CENTRAL_USERNAME}" >> gradle.properties | |
echo "mavenCentralPassword=${MAVEN_CENTRAL_PASSWORD}" >> gradle.properties | |
echo "signing.keyId=${SIGNING_KEY_ID}" >> gradle.properties | |
echo "signing.password=${SIGNING_KEY_PASSWORD}" >> gradle.properties | |
echo "signing.secretKeyRingFile=${HOME}/secring.gpg" >> gradle.properties | |
- name: Setup Xcode | |
uses: maxim-lobanov/setup-xcode@v1 | |
with: | |
xcode-version: latest-stable | |
- name: Publish To Maven Central | |
run: | | |
./gradlew publishAndReleaseToMavenCentral --no-configuration-cache | |
- name: Read Changelog | |
id: read_changelog | |
run: | | |
changelog=$(cat CHANGELOG.md) | |
echo "CHANGELOG<<EOF" >> $GITHUB_ENV | |
echo "$changelog" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Prepare version for file name | |
id: prepare_version | |
run: | | |
version=$(cat version.txt) | |
sanitized_version=${version//./_} | |
echo "SANITIZED_VERSION=$sanitized_version" >> $GITHUB_ENV | |
echo "VERSION_NUMBER=$version" >> $GITHUB_ENV | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.VERSION_NUMBER }} | |
release_name: KaptureX ${{ env.VERSION_NUMBER }} | |
body: | | |
## Changelog | |
${{ env.CHANGELOG }} |