Update README.md #61
This file contains hidden or 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 Materia | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| env: | |
| GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.vfs.watch=false" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Grant execute permissions | |
| run: | | |
| chmod +x gradlew | |
| if [ -f sign-artifact.sh ]; then | |
| chmod +x sign-artifact.sh | |
| fi | |
| - name: Set up Temurin JDK 22 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '22' | |
| distribution: 'temurin' | |
| - name: Set up Android SDK | |
| uses: android-actions/setup-android@v3 | |
| - name: Install Rust and naga-cli for shader compilation | |
| run: | | |
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
| source "$HOME/.cargo/env" | |
| cargo install naga-cli | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| - name: Cache Gradle and build outputs | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| ~/.gradle/nodejs | |
| build | |
| */build | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts', '**/gradle.properties', 'gradle/libs.versions.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Verify version matches tag | |
| id: version | |
| shell: bash | |
| run: | | |
| VERSION=$(grep "^VERSION=" version.properties | cut -d'=' -f2) | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| if [[ -f CHANGELOG.md ]]; then | |
| CHANGELOG_VERSION=$(sed -n 's/^## \[\([^]]*\)\].*/\1/p' CHANGELOG.md | head -n 1) | |
| if [[ -n "$CHANGELOG_VERSION" && "$CHANGELOG_VERSION" != "$VERSION" ]]; then | |
| echo "::error::Latest CHANGELOG.md version $CHANGELOG_VERSION does not match version.properties $VERSION" | |
| exit 1 | |
| fi | |
| fi | |
| if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then | |
| TAG="${GITHUB_REF_NAME}" | |
| if [[ "$TAG" != "v$VERSION" ]]; then | |
| echo "::error::Tag $TAG does not match version v$VERSION from version.properties" | |
| exit 1 | |
| fi | |
| fi | |
| - name: Run tests | |
| run: | | |
| ./gradlew --no-daemon --max-workers=4 --console=plain \ | |
| :materia-gpu:jvmTest \ | |
| :materia-engine:jvmTest \ | |
| :materia-validation:jvmTest \ | |
| :jvmTest \ | |
| --stacktrace | |
| env: | |
| GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g" | |
| timeout-minutes: 20 | |
| - name: Compile native metadata | |
| run: | | |
| ./gradlew --no-daemon --max-workers=4 --console=plain \ | |
| :compileNativeMainKotlinMetadata \ | |
| --stacktrace | |
| env: | |
| GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g" | |
| timeout-minutes: 10 | |
| - name: Ensure tag does not already exist | |
| shell: bash | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| if git ls-remote --tags origin "refs/tags/v${VERSION}" | grep -q .; then | |
| echo "::error::Tag v${VERSION} already exists. Bump version.properties before releasing." | |
| exit 1 | |
| fi | |
| - name: Ensure publishing secrets are present | |
| shell: bash | |
| run: | | |
| [[ -n "${{ secrets.CENTRAL_USERNAME }}" ]] || { echo "::error::Missing required secret CENTRAL_USERNAME"; exit 1; } | |
| [[ -n "${{ secrets.CENTRAL_PASSWORD }}" ]] || { echo "::error::Missing required secret CENTRAL_PASSWORD"; exit 1; } | |
| [[ -n "${{ secrets.CENTRAL_SIGNING_PASSWORD }}" ]] || { echo "::error::Missing required secret CENTRAL_SIGNING_PASSWORD"; exit 1; } | |
| [[ -n "${{ secrets.CENTRAL_SIGNING_KEY_ASC }}" ]] || { echo "::error::Missing required secret CENTRAL_SIGNING_KEY_ASC"; exit 1; } | |
| - name: Configure publishing credentials | |
| shell: bash | |
| run: | | |
| cat <<'EOF' > local.properties | |
| sdk.dir=$ANDROID_HOME | |
| mavenCentralUsername=${{ secrets.CENTRAL_USERNAME }} | |
| mavenCentralPassword=${{ secrets.CENTRAL_PASSWORD }} | |
| signingPassword=${{ secrets.CENTRAL_SIGNING_PASSWORD }} | |
| signingKey=provided-via-secret | |
| EOF | |
| SIGNING_SECRET="${{ secrets.CENTRAL_SIGNING_KEY_ASC }}" | |
| if [[ -z "$SIGNING_SECRET" ]]; then | |
| echo "::error::CENTRAL_SIGNING_KEY_ASC secret is not set" | |
| exit 1 | |
| fi | |
| if echo "$SIGNING_SECRET" | base64 -d > private-key.asc 2>/tmp/base64-decode.log; then | |
| echo "Imported signing key from base64-encoded secret" | |
| else | |
| echo "$SIGNING_SECRET" > private-key.asc | |
| echo "Stored signing key as literal ASCII-armored block" | |
| fi | |
| chmod 600 private-key.asc | |
| # Validate the signing key is importable before proceeding (fail fast) | |
| TMP_GNUPGHOME=$(mktemp -d) | |
| export GNUPGHOME="$TMP_GNUPGHOME" | |
| if ! gpg --batch --yes --import private-key.asc >/tmp/gpg-import.log 2>&1; then | |
| echo "::error::Signing key could not be imported" | |
| cat /tmp/gpg-import.log || true | |
| rm -rf "$TMP_GNUPGHOME" | |
| exit 1 | |
| fi | |
| rm -rf "$TMP_GNUPGHOME" | |
| - name: Publish Materia to Maven Central | |
| run: ./gradlew publishToCentralPortal --stacktrace --info --no-configuration-cache | |
| - name: Extract latest changelog entry | |
| id: changelog | |
| shell: bash | |
| run: | | |
| if [ -f CHANGELOG.md ]; then | |
| python3 <<'PY' | |
| import itertools | |
| with open("CHANGELOG.md", encoding="utf-8") as fh: | |
| lines = fh.readlines() | |
| section = [] | |
| capture = False | |
| for line in lines: | |
| if line.startswith("## ["): | |
| if capture: | |
| break | |
| capture = True | |
| continue | |
| if capture: | |
| section.append(line.rstrip("\n")) | |
| notes = "\n".join(section).strip() | |
| print(notes) | |
| with open("release-notes.md", "w", encoding="utf-8") as out: | |
| out.write(notes + "\n") | |
| PY | |
| else | |
| echo "Initial release" > release-notes.md | |
| fi | |
| NOTES=$(cat release-notes.md) | |
| echo "notes<<EOF" >> "$GITHUB_OUTPUT" | |
| echo "$NOTES" >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| - name: Create and push release tag | |
| shell: bash | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "v${VERSION}" -m "Materia ${VERSION}" | |
| git push origin "v${VERSION}" | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| name: Materia ${{ steps.version.outputs.version }} | |
| body_path: release-notes.md | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |