-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: AtomicFS <[email protected]>
- Loading branch information
Showing
5 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
# Update versions and create release PR | ||
# Source: https://www.thisdot.co/blog/tag-and-release-your-project-with-github-actions-workflows | ||
# | ||
# For detailed description see "release.yml" | ||
|
||
name: release-prepare | ||
on: workflow_dispatch | ||
|
||
permissions: | ||
contents: write # To push new branch | ||
pull-requests: write # To create a pull request | ||
|
||
jobs: | ||
release-prepare: | ||
name: version_bump | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
|
||
# Automatically determinate the next release version from Conventional Commits since the latest tag | ||
- name: Get next version | ||
id: semver | ||
uses: ietf-tools/semver-action@v1 | ||
with: | ||
token: ${{ github.token }} | ||
branch: main | ||
|
||
# Bump version | ||
- name: Update main.go | ||
run: | | ||
sed -i -E 's/const bmcTestGoVersion = .*/const bmcTestGoVersion = "${{ steps.semver.outputs.next }}"/g' main.go | ||
# Changelog | ||
- name: Get cocogitto | ||
run: | | ||
cargo install --locked cocogitto | ||
- name: Update changelog | ||
run: | | ||
cog changelog > CHANGELOG.md | ||
- name: Create pull request | ||
id: create_pr | ||
uses: peter-evans/create-pull-request@v7 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: release/${{ steps.semver.outputs.next }} | ||
commit-message: 'chore: bump version to ${{ steps.semver.outputs.next }}' | ||
title: 'Release: ${{ steps.semver.outputs.next }} Pull Request' | ||
body: 'Prepare for next release' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
# Update versions and create release PR | ||
# Source: https://www.thisdot.co/blog/tag-and-release-your-project-with-github-actions-workflows | ||
# https://goreleaser.com/ci/actions/#tag-fetching | ||
# | ||
# - Manually triggered "release-prepare.yml" workflow will create a PR | ||
# - This PR will do some minor tweaks to ready for release (such as increment the version across files) | ||
# - Upon merging the PR, "release" job defined here will trigger, which will: | ||
# - create a tag | ||
# - do the actual release with goreleaser | ||
|
||
name: release | ||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
release-golang: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write # To create a new release | ||
if: startsWith(github.event.pull_request.title, 'Release:') && github.event.pull_request.merged == true | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
|
||
- name: Set up Git | ||
run: | | ||
git config user.name "Release bot" | ||
git config user.email "[email protected]" | ||
- name: Get current version | ||
id: get_version | ||
run: | | ||
git branch --show-current | ||
git pull | ||
echo "version=$(grep 'const bmcTestGoVersion' < main.go | sed -E 's/.*= "//g' | sed 's/"//g')" >> "${GITHUB_OUTPUT}" | ||
# Can't really use cocogitto here | ||
- name: Create tag | ||
run: | | ||
NEXT_VERSION=${{ steps.get_version.outputs.version }} | ||
git pull | ||
git tag -a "${NEXT_VERSION}" -m "${NEXT_VERSION}" | ||
git push --follow-tags | ||
git checkout "${NEXT_VERSION}" | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v6 | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Empty file.
This file contains 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