-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ci): Add action for bumb version #253
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
name: Bumb version | ||
|
||
on: | ||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
inputs: | ||
versionBumb: | ||
description: 'Version bumb' | ||
required: true | ||
default: 'patch' | ||
type: choice | ||
options: | ||
- major # Increases the major of the latest tag. | ||
- minor # Increases the minor of the latest tag. | ||
- patch # Increases the patch of the latest tag. | ||
|
||
jobs: | ||
bumb-version: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 | ||
with: | ||
go-version: 1.19.x | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
fetch-depth: 0 | ||
|
||
# cache go modules | ||
- uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d # v3.2.2 | ||
with: | ||
# In order: | ||
# * Module download cache | ||
# * Build cache (Linux) | ||
# * Build cache (Mac) | ||
# * Build cache (Windows) | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
~/Library/Caches/go-build | ||
%LocalAppData%\go-build | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
|
||
- name: Bumb version file | ||
run: make svu args=${{ inputs.versionBumb }} | ||
|
||
- name: Get version from file | ||
id: tag | ||
run: | | ||
export VERSION="$(cat config/version.txt)" | ||
echo "tag=v$VERSION" >> $GITHUB_OUTPUT | ||
echo "branch=version-bumb/v$VERSION" >> $GITHUB_OUTPUT | ||
|
||
- name: Commit changes | ||
run: | | ||
git checkout -b "${{ steps.tag.outputs.branch }}" | ||
git config --local user.email "action@github.com" | ||
git config --local user.name "GitHub Action" | ||
git add config/version.txt | ||
git commit -m "chore(engine): prepare release ${{ steps.tag.outputs.tag }}" | ||
|
||
- name: Create Pull Request | ||
run: | | ||
git push --set-upstream origin "${{ steps.tag.outputs.branch }}" | ||
gh pr create --fill | ||
env: | ||
GH_TOKEN: ${{ github.token }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
name: tag-release | ||
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- main | ||
types: | ||
- closed | ||
paths: | ||
- "config/version.txt" | ||
|
||
jobs: | ||
tag: | ||
if: github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | ||
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0 | ||
# using a PAT is necessary to trigger the release workflow | ||
# see https://github.com/orgs/community/discussions/25702 | ||
with: | ||
|
@@ -33,3 +36,5 @@ jobs: | |
run: | | ||
git tag ${{ steps.tag.outputs.tag }} | ||
git push --tags | ||
- name: Create release | ||
run: gh release create {{ steps.tag.outputs.tag }} --verify-tag --generate-notes | ||
Comment on lines
+39
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really understand this change. The workflow should just create the tag and let the release workflow (with goreleaser) take care of creating the release with proper assets. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,10 @@ testing-project-ci: ## Creates for all yml files in ./test_project_values a tes | |
make testing-project-ci-single VALUES_FILE=$$VALUES; \ | ||
done | ||
|
||
svu: ## Creates a new version, args options major, minor & patch | ||
@go run github.com/caarlos0/svu $(args) --strip-prefix > config/version.txt | ||
@go run github.com/caarlos0/svu $(args) | ||
|
||
Comment on lines
+96
to
+99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
.PHONY: release | ||
release: ## Create a new release version | ||
@./hack/release.sh | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//go:build tools | ||
// +build tools | ||
|
||
package main | ||
|
||
import ( | ||
// version bumping | ||
// https://github.com/caarlos0/svu | ||
_ "github.com/caarlos0/svu" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we somehow reuse the
hack/release.sh
script here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thanks for the reminder, I forget to take a look into it. I was mostly gone through a tutorial.