Skip to content

Commit

Permalink
feat(ci)!: enable semantic releases (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChipWolf authored Dec 5, 2024
1 parent 42445f0 commit 7d69be4
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 20 deletions.
22 changes: 22 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": [
":enableRenovate",
":semanticCommits",
":enablePreCommit",
":pinDependencies"
],
"platform": "github",
"onboarding": false,
"requireConfig": "optional",
"timezone": "UTC",
"dependencyDashboard": true,
"platformCommit": true,
"prCreation": "not-pending",
"suppressNotifications": ["prIgnoreNotification"],
"rebaseWhen": "conflicted",
"packageRules": [
{"matchUpdateTypes": ["major"], "addLabels": ["dependency/major"]},
{"matchUpdateTypes": ["minor"], "addLabels": ["dependency/minor"]},
{"matchUpdateTypes": ["patch"], "addLabels": ["dependency/patch"]}
]
}
4 changes: 3 additions & 1 deletion .github/workflows/flex-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ name: Flex Build
type: boolean

jobs:
build:
build: # TODO: add build attestation and generate then combine gradle dependency graphs for SBOM
name: Build ${{ inputs.dir }}/${{ inputs.mc }}
runs-on: ubuntu-22.04
steps:
Expand Down Expand Up @@ -60,6 +60,8 @@ jobs:
- if: steps.cache.outputs.cache-hit != 'true'
name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
workflow-job-context: '{}' # FIXME: avoid this cache duplication workaround

- if: |
steps.cache.outputs.cache-hit != 'true'
Expand Down
59 changes: 44 additions & 15 deletions .github/workflows/lifecycle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Lifecycle

"on":
push:
tags:
- '**'
branches:
- main
pull_request:
Expand All @@ -22,17 +20,35 @@ name: Lifecycle
description: Git ref to checkout before build (i.e. my-feature-branch )
default: "main"

concurrency:
concurrency: # FIXME: prevent release commit cancellation
group: >
${{ github.workflow }}-
${{ github.event_name }}
${{ github.event_name }}-
${{ github.event.inputs.ref || github.ref }}
cancel-in-progress: true

jobs:
release-please:
name: Release Please
runs-on: ubuntu-22.04
outputs:
release_created: ${{ steps.release-please.outputs.release_created }}
tag_name: ${{ steps.release-please.outputs.tag_name }}
permissions:
contents: write
pull-requests: write
steps:
- if: github.event_name == 'push' # TODO: explicit on push to main
id: release-please
name: Run Release Please
uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

matrices:
if: github.event.action != 'closed'
name: Construct matrices
needs: release-please
runs-on: ubuntu-22.04
outputs:
build-matrix: ${{ steps.matrices.outputs.build-matrix }}
Expand Down Expand Up @@ -64,7 +80,7 @@ jobs:
filters: |
${{ steps.paths.outputs.filter }}
- id: matrices # TODO: build origin matrices dynamically
- id: matrices # TODO: build origin matrices dynamically, consider collapsing this into a .py
name: Construct matrices
run: |
import os
Expand Down Expand Up @@ -162,8 +178,8 @@ jobs:
dirs_to_filter = [item.strip() for item in input_dirs.split(',')]
case 'push':
if '${{ github.ref }}'.startswith('refs/tags/'):
# If a tag is pushed, use the full matrices
if '${{ needs.release-please.outputs.release_created }}' == 'true':
# If a release is created, use the full matrices
build_matrix['include'], run_matrix['version'] = build_data, run_data
else:
# Otherwise, filter directories based on the detected changes
Expand Down Expand Up @@ -199,6 +215,7 @@ jobs:
java: ${{ matrix.java }}

run:
if: github.event_name != 'push'
name: Run tests
needs:
- matrices
Expand Down Expand Up @@ -244,8 +261,10 @@ jobs:
headlessmc-command: ${{ !matrix.xvfb && '-lwjgl' || '' }} --retries 3 --jvm -Djava.awt.headless=true

release:
if: startsWith(github.ref, 'refs/tags/')
needs: run
if: needs.release-please.outputs.release_created == 'true'
needs:
- release-please
- build
name: Release
permissions:
contents: write
Expand All @@ -254,13 +273,23 @@ jobs:
- name: Download artifacts
uses: actions/download-artifact@v4

- name: Release
uses: softprops/action-gh-release@v2
- name: Upload release artifacts
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: jars-*/*-release.jar
tag: ${{ needs.release-please.outputs.tag_name }}
overwrite: true
file_glob: true

- name: Upload api artifacts
uses: svenstaro/upload-release-action@v2
with:
generate_release_notes: true
files: |
jars-*/*-release.jar
jars-*/*-api*.jar
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: jars-*/*-api-*.jar # TODO: make API jar names consistent with release jars, then simplify away this step
tag: ${{ needs.release-please.outputs.tag_name }}
overwrite: true
file_glob: true

clean: # TODO: run this conditionally per #22
name: Clean up
Expand Down
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "2.4.2"
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ You can configure it to use any other version, but in that case you need to set
</div>

Versions marked with :warning: have not been tested yet, due to not being supported by HeadlessMC, e.g. fabric legacy versions.

<!-- x-release-please-start-version -->
# Example
```yml
name: Run the MC client
Expand Down Expand Up @@ -85,6 +85,7 @@ jobs:
mc-runtime-test: fabric
java: ${{ env.java_version }}
```
<!-- x-release-please-end -->
An example workflow in action can be found
[here](https://github.com/3arthqu4ke/hmc-optimizations/blob/1.20.4/.github/workflows/run-fabric.yml).
An example for a large matrix workflow
Expand Down
7 changes: 4 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,14 @@ runs:
fi
shell: bash

- if: inputs.mc-runtime-test != 'none'
- id: get-mcrt
if: inputs.mc-runtime-test != 'none'
name: Get mc-runtime-test
uses: robinraju/release-downloader@v1.11
with:
repository: 3arthqu4ke/mc-runtime-test
tag: "2.4.2"
fileName: mc-runtime-test-${{ inputs.mc }}-2.4.2-${{ inputs.mc-runtime-test }}-release.jar
tag: "2.4.2" # x-release-please-version
fileName: 'mc-runtime-test-${{ inputs.mc }}-*-${{ inputs.mc-runtime-test }}-release.jar'
out-file-path: run/mods

- if: inputs.fabric-api != 'none'
Expand Down
2 changes: 2 additions & 0 deletions api/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# x-release-please-start-version
project_version = 2.4.2
# x-release-please-end
17 changes: 17 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"bootstrap-sha": "42445f09578667ad2a3b620ca669ba1c13c1c1ac",
"packages": {
".": {
"include-component-in-tag": false,
"include-v-in-tag": false,
"package-name": "mc-runtime-test",
"release-type": "simple",
"extra-files": [
"action.yml",
"api/gradle.properties",
"README.md"
]
}
}
}

0 comments on commit 7d69be4

Please sign in to comment.