Skip to content

Commit

Permalink
feat: setup release-please for repo, blog docker image
Browse files Browse the repository at this point in the history
* ci: add release-please

* ci: fixing dockerfile ref in github action

* ci: updating dependabot commit message prefix to chore: and buildblog name

* ci: updating docker/build-push-action

* ci: adding basic release-please config
  • Loading branch information
jonshaffer authored Sep 23, 2024
1 parent c7a9efc commit 16b2c46
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 8 deletions.
6 changes: 5 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ updates:
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "chore: "
- package-ecosystem: "docker"
directories:
- "/blog"
schedule:
interval: "weekly"
interval: "weekly"
commit-message:
prefix: "chore: "
17 changes: 10 additions & 7 deletions .github/workflows/build.yaml → .github/workflows/build-blog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Publish Docker image
name: Test Blog Docker image

on:
pull_request
pull_request:
paths:
- "/blog"
- ".github/workflows/build-blog.yaml"

jobs:
push_to_registry:
name: Push Docker image to GitHub Registry
build_image:
name: Build Docker image
runs-on: ubuntu-latest
permissions:
packages: write
Expand All @@ -25,10 +28,10 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v4

- name: Build and push Docker image
- name: Build Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85
with:
context: ./blog
file: ./Dockerfile
file: ./blog/Dockerfile
push: false
68 changes: 68 additions & 0 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Release Please action

on:
push:
branches:
- main

jobs:
release_please:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
paths_released: ${{ steps.release.outputs.paths_released }}
releases_created: ${{ steps.release.outputs.releases_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.GH_RELEASE_PLEASE_TOKEN }}
config-file: release-please-config.json
manifest-file: .release-please-manifest.json

publish_image:
if: ${{ steps.release.outputs['Home/Areas/Blogs--release_created'] }}
runs-on: ubuntu-latest
needs: release_please
strategy:
matrix:
path: ${{ fromJson(needs.release_please.outputs.paths_released) }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- run: echo "BUILDCONFIG=$(jq -c . < ${{ matrix.path }}/buildconfig.json)" >> $GITHUB_ENV
- run: echo '${{ fromJson(env.BUILDCONFIG).version }}'

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
hyperfluid-solutions/${{ matrix.path }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}},value=${{ fromJson(env.BUILDCONFIG).version }}
type=semver,pattern={{major}}.{{minor}},value=${{ fromJson(env.BUILDCONFIG).majorminor }}
type=semver,pattern={{major}},value=${{ fromJson(env.BUILDCONFIG).major }}
type=sha
- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: ${{ fromJson(env.PACKAGE_JSON).platforms }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"blog": "0.0.1"
}
6 changes: 6 additions & 0 deletions blog/buildconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": "0.0.1",
"major": "0",
"majorminor": "0.0",
"platforms": "linux/amd64,linux/arm64"
}
1 change: 1 addition & 0 deletions blog/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1
26 changes: 26 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"packages": {
"blog": {
"release-type": "simple",
"initial-version": "0.0.1",
"extra-files": [
{
"type": "json",
"path": "buildconfig.json",
"jsonpath": "$.version"
},
{
"type": "json",
"path": "buildconfig.json",
"jsonpath": "$.major"
},
{
"type": "json",
"path": "buildconfig.json",
"jsonpath": "$.majorminor"
}
]
}
}
}

0 comments on commit 16b2c46

Please sign in to comment.