Skip to content

Commit

Permalink
Merge pull request #38 from btnguyen2k/release
Browse files Browse the repository at this point in the history
Merge to main after releasing new version 0.1.1
  • Loading branch information
btnguyen2k authored Nov 26, 2023
2 parents 3e13928 + 575b971 commit 76ef75d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
env:
BRANCH_TO_RELEASE: 'release'
TAG_PREFIX: 'v'
FILE_CHANGELOG: 'RELEASE-NOTES.md'
FILE_MODULE: 'module.go'

jobs:
CallCI:
Expand Down Expand Up @@ -69,8 +71,6 @@ jobs:
if [ "${RESULT}" == "SUCCESS" ]; then
DATE=`date +%Y-%m-%d`
FILE_CHANGELOG="RELEASE-NOTES.md"
FILE_MODULE="module.go"
head -1 ${FILE_CHANGELOG} > .temp.md
echo -e "\n## ${DATE} - v${VERSION}\n\n${RELEASE_NOTES}" >> .temp.md
tail -n +2 ${FILE_CHANGELOG} >> .temp.md
Expand Down Expand Up @@ -98,6 +98,28 @@ jobs:
else
echo "❎ SKIPPED."
fi
- name: Create release
uses: actions/github-script@v7
env:
RESULT: ${{ needs.ReleaseDryRun.outputs.RESULT }}
VERSION: ${{ needs.ReleaseDryRun.outputs.VERSION }}
RELEASE_NOTES: ${{ needs.ReleaseDryRun.outputs.RELEASE_NOTES }}
with:
script: |
if (process.env['RESULT'] != 'SUCCESS') {
console.log('❎ SKIPPED.');
return;
}
const {data: release} = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: process.env['TAG_PREFIX'] + process.env['VERSION'],
name: process.env['TAG_PREFIX'] + process.env['VERSION'],
body: process.env['RELEASE_NOTES'],
draft: false,
prerelease: false,
});
console.log('✅ Created release: ', release);
MergeToMain:
runs-on: ubuntu-latest
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ Template to quickly spin up a Go module project.
- (Less preferred method) Or simply clone/fork this repository.
2. Update `go.mod` and `module.go` file to reflect your module name and required Go version.
3. Review other source code and test files, either update them to reflect your module's name and functionality or remove them.
4. `LICENSE.tpl.md`, `README.tpl.md` and `RELEASE-NOTES.tpl.md` files are templates. Update them to reflect your module's name and functionality. Then rename them to `LICENSE.md`, `README.md` and `RELEASE-NOTES.md`.
4. `LICENSE.tpl.md`, `README.tpl.md` and `RELEASE-NOTES.tpl.md` files are templates; update them to reflect your module's name and functionality; then rename them to `LICENSE.md`, `README.md` and `RELEASE-NOTES.md`.
5. Update other files to suit your needs.
6. Happy coding!

**Workflows**

Workflows implemented by this template are as the following:

- Dependencies are checked and updated weekly by `dependabot.yaml`, and then PRs are automatically merged to `main` branch by `automerge-dependabot.yaml`.
- `dependabot.yaml` configures dependencies are checked and updated weekly. `dependabot` will create a PR for each dependency update. `automerge-dependabot.yaml` is triggered to automatically merged PRs to `main` branch.
- `ci.yaml` is triggered on every push to any branch to run tests and generate code coverage report.
- Once PR is approved and merged to `release` branch, `release.yaml` is triggered to create a new release. Then a new PR is created to merge `release` branch to `main` branch.

A suggested git workflow to use with this template is as the following:

- Work on your code in development/feature branches as usual.
- Once ready, create a PR to merge your development/feature branch to `release` branch.
- Workflow `release.yaml` will be triggered to create a new release.
- Then a new PR will be created to merge `release` branch to `main` branch. Note: you have to review and approve the PR by yourself to finalize the merge.
- Once the PR is merged, `release.yaml` is triggered to create a new release.
- Then a new PR is created to merge `release` branch to `main` branch. Note: you have to review and approve the PR by yourself to finalize the merge.

> Remember to enable the setting "Allow GitHub Actions to create and approve pull requests" from project's `Settings -> Actions -> General`.
Expand Down
6 changes: 6 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# go-module-template release notes

## 2023-11-26 - v0.1.1

### Fixed/Improvement

- Fix action release to actually create a release package

## 2023-11-26 - v0.1.0

Template for Go module projects:
Expand Down
2 changes: 1 addition & 1 deletion module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package mymodule

const (
// Version holds the semantic version number of this module.
Version = "0.1.0"
Version = "0.1.1"
)

// This file contains module's metadata only, which is package level documentation and module Version string.
Expand Down

0 comments on commit 76ef75d

Please sign in to comment.