Skip to content

Commit

Permalink
Use latest release for baseVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
rradczewski committed Jan 16, 2025
1 parent 553c7c1 commit e61e6bf
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,18 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: octokit/request-action@v2.x
id: get_latest_release
with:
route: GET /repos/{repo}/releases/latest
repo: ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate trunkver
id: trunkver
uses: crftd-tech/trunkver@main
with:
baseVersion: "1.0.0"
baseVersion: ${{ fromJson(steps.get_latest_release.outputs.data).tag_name }}
prerelease: "true"

build-release:
Expand Down
80 changes: 80 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
required: true
description: The version to release

permissions:
packages: write
contents: write

jobs:
build-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/crftd-tech/trunkver
tags: |
type=raw,value=${{ github.event.inputs.version }}
type=raw,value=latest
- name: Log in to the Container registry
uses: docker/login-action@327cd5a69de6c009b9ce71bce8395f28e651bf99
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@31ca4e5d51253d7e4a2317bfe74699cbe3a398a9
with:
context: .
build-args: |
VERSION=${{ github.event.inputs.version }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Update the action.yml with the new image tag
run: |
yq eval --inplace '.runs.image = "docker://ghcr.io/crftd-tech/trunkver:${{ github.event.inputs.version }}"' action.yml
git config --global user.email "bot@crftd.tech"
git config --global user.name "crftd-bot"
git add action.yml
git commit -m "chore: Bump image tag in action.yml"
git pull origin --rebase
git push origin
build-release:
runs-on: ubuntu-latest
needs: [build-docker]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Build trunkver
env:
VERSION: ${{ github.event.inputs.version }}
run: |
(
unset GITHUB_SHA
unset GITHUB_RUN_ID
make test all spec "VERSION=${VERSION}"
)
- name: Create release
id: release
uses: softprops/action-gh-release@v2
with:
name: ${{ github.event.inputs.version }}
tag_name: ${{ github.event.inputs.version }}
files: |
out/trunkver*

0 comments on commit e61e6bf

Please sign in to comment.