Skip to content

Commit

Permalink
Add release workflow (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt authored Mar 6, 2024
1 parent 412f04f commit b0eb592
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
java-version: 17
distribution: 'graalvm-community'
set-java-home: false
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
- uses: actions/checkout@v4
- name: Fetch git tags
run: git fetch origin +refs/tags/*:refs/tags/*
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: release

on:
push:
tags:
- '**'

jobs:
release:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: ./gradlew publishToMavenCentral
env:
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralPassword }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKey }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralUsername }}
- name: Extract release notes
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v2
- name: Create release
uses: ncipollo/release-action@v1
with:
body: ${{ steps.extract-release-notes.outputs.release_notes }}
- name: Dokka
uses: gradle/actions/setup-gradle@v3
with:
arguments: dokkaHtmlMultiModule
- run : ./prepare_docs.sh
- name: Build mkdocs
run: |
pip install mkdocs-material
mkdocs build
- name: Deploy docs to website
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: site
13 changes: 2 additions & 11 deletions buildSrc/src/main/kotlin/mordant-publishing-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,9 @@ plugins {

fun getPublishVersion(): String {
val version = project.property("VERSION_NAME").toString()
// Call gradle with -PinferVersion to set the dynamic version name.
// Call gradle with -PsnapshotVersion to set the version as a snapshot.
// Otherwise, we skip it to save time.
if (!project.hasProperty("inferVersion")) return version

val stdout = ByteArrayOutputStream()
project.exec {
commandLine = listOf("git", "tag", "--points-at", "master")
standardOutput = stdout
}
val tag = String(stdout.toByteArray()).trim()
if (tag.isNotEmpty()) return tag

if (!project.hasProperty("snapshotVersion")) return version
val buildNumber = System.getenv("GITHUB_RUN_NUMBER") ?: "0"
return "$version.$buildNumber-SNAPSHOT"
}
Expand Down
20 changes: 7 additions & 13 deletions deploy_website.sh → prepare_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

# The website is built using MkDocs with the Material theme.
# https://squidfunk.github.io/mkdocs-material/
# It requires Python to run.
# Install the packages with the following command:
# pip install mkdocs mkdocs-material
# Mkdocs requires Python to run.
# Install the packages: `pip install mkdocs-material`
# Build the api docs: `./gradlew dokkaHtmlMultiModule`
# Then run this script to prepare the docs for the website.
# Finally, run `mkdocs serve` to preview the site locally or `mkdocs build` to build the site.

set -ex

# Generate API docs
./gradlew dokkaHtmlMultiModule

# Copy the changelog into the site, omitting the unreleased section
cat CHANGELOG.md \
| grep -v '^## Unreleased' \
Expand All @@ -26,15 +25,10 @@ hide:
EOM

# Copy the README into the index, omitting the license and fixing hrefs
# Copy the README into the index, omitting the docs link, license and fixing hrefs
cat README.md \
| sed '/## License/Q' \
| sed -z 's/## Documentation[a-zA-z .\n()/:]*//g' \
| sed 's!https://ajalt.github.io/mordant/!/!g' \
| sed 's!docs/img!img!g' \
>> docs/index.md

# Build and deploy the new site to github pages
mkdocs gh-deploy

# Remove the file copies
rm docs/index.md docs/changelog.md

0 comments on commit b0eb592

Please sign in to comment.