Build #1963
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: Build | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
release: | |
types: [created] | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
build: | |
name: Build | |
strategy: | |
matrix: | |
gradle-version: [ 'current' ] | |
kotlin-version: [ '' ] | |
include: | |
- gradle-version: '7.6.4' | |
kotlin-version: '1.7.20' | |
- gradle-version: '8.1.1' | |
kotlin-version: '1.8.10' | |
- gradle-version: '8.2.1' | |
kotlin-version: '1.8.20' | |
- gradle-version: '8.3' | |
kotlin-version: '1.9.0' | |
- gradle-version: '8.5' | |
kotlin-version: '1.9.10' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Determine the version | |
# Updates the build version to the tag if it's a release. | |
# Otherwise updates the build version to latest tag with the branch name as a suffix (i.e. 1.0.0-feature-upload). | |
run: | | |
LAST_VERSION=$(git describe --abbrev=0 --tags 2>/dev/null || echo 0.0.0) | |
INCR_VERSION=$(echo $LAST_VERSION | awk -F. -v OFS=. '{$NF++; print}') | |
VERSION_SUFFIX=$(echo ${{ github.head_ref }} | sed -e 's/^refs\///' -e 's/[^0-9a-zA-Z\-_]/-/g' -e 's/^$/SNAPSHOT/') | |
BUILD_VERSION=$([[ "${{ github.event_name }}" == "release" ]] && echo $LAST_VERSION || echo "$INCR_VERSION-$VERSION_SUFFIX") | |
sed -i'' -e "/^version=/s/=.*/=$BUILD_VERSION/" gradle.properties | |
echo $BUILD_VERSION | |
echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: 'zulu' | |
- name: Configure gradle ${{ matrix.gradle-version }} | |
run: sed -i.bkp -e 's/\(distributionUrl=.*gradle\)-[0-9]*\.[0-9]*\(\.[0-9]*\)\{0,1\}\(.*\)/\1-${{ matrix.gradle-version }}\3/' gradle/wrapper/gradle-wrapper.properties | |
if: ${{ matrix.gradle-version != 'current' }} | |
- name: Build | |
run: | | |
[ "${{matrix.kotlin-version}}" == '' ] || ./gradlew build --stacktrace -PkotlinVersion=${{matrix.kotlin-version}} | |
[ "${{matrix.kotlin-version}}" != '' ] || ./gradlew build --stacktrace | |
- name: Upload artifacts | |
if: ${{ matrix.gradle-version == 'current' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: jars | |
path: build/libs/*.jar | |
- name: Upload artifacts to the release | |
if: ${{ matrix.gradle-version == 'current' && github.event_name == 'release' }} | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ./build/libs/gradle-structurizr-cli-${{ env.BUILD_VERSION }}.jar | |
asset_name: gradle-structurizr-cli-${{ env.BUILD_VERSION }}.jar | |
asset_content_type: application/zip | |
- name: Publish | |
if: ${{ matrix.gradle-version == 'current' && github.event_name == 'release' }} | |
run: ./gradlew publishPlugins -Pgradle.publish.key="$GRADLE_PUBLISH_KEY" -Pgradle.publish.secret="$GRADLE_PUBLISH_SECRET" | |
env: | |
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }} | |
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }} |