generated from atomicgo/template
-
-
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.
- Loading branch information
0 parents
commit 4fdb1c7
Showing
18 changed files
with
875 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
# β β | ||
# β IMPORTANT NOTE β | ||
# β β | ||
# β This file is synced with https://github.com/atomicgo/template β | ||
# β β | ||
# β Please apply all changes to the template repository β | ||
# β β | ||
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
|
||
changelog: | ||
exclude: | ||
labels: | ||
- ignore-for-release | ||
authors: | ||
- octocat | ||
categories: | ||
- title: Breaking Changes π | ||
labels: | ||
- breaking | ||
- title: Exciting New Features π | ||
labels: | ||
- feature | ||
- title: Fixes π§ | ||
labels: | ||
- fix | ||
- title: Other Changes | ||
labels: | ||
- "*" |
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,20 @@ | ||
_extends: .github | ||
|
||
repository: | ||
# See https://developer.github.com/v3/repos/#edit for all available settings. | ||
|
||
# A short description of the repository that will show up on GitHub | ||
description: π¦ Template repository for AtomicGo repositories | ||
|
||
# A comma-separated list of topics to set on the repository | ||
topics: atomicgo, hacktoberfest, go, golang, golang-library | ||
|
||
# Either `true` to enable issues for this repository, `false` to disable them. | ||
has_issues: true | ||
|
||
# Either `true` to enable projects for this repository, or `false` to disable them. | ||
# If projects are disabled for the organization, passing `true` will cause an API error. | ||
has_projects: false | ||
|
||
# Either `true` to enable the wiki for this repository, `false` to disable it. | ||
has_wiki: false |
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,190 @@ | ||
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
# β β | ||
# β IMPORTANT NOTE β | ||
# β β | ||
# β This file is synced with https://github.com/atomicgo/template β | ||
# β β | ||
# β Please apply all changes to the template repository β | ||
# β β | ||
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
|
||
name: AtomicGo | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
jobs: | ||
test: | ||
name: Test Go Code | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: stable | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get dependencies | ||
run: go get -v -t -d ./... | ||
|
||
- name: Build | ||
run: go build -v . | ||
|
||
- name: Test | ||
run: go test -coverprofile="coverage.txt" -covermode=atomic -v -p 1 . | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
|
||
build: | ||
name: Build AtomicGo Package | ||
runs-on: ubuntu-latest | ||
needs: test | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Download assets | ||
run: | | ||
mkdir -p .templates | ||
wget https://raw.githubusercontent.com/atomicgo/atomicgo/main/templates/example.gotxt -O .templates/example.gotxt | ||
wget https://raw.githubusercontent.com/atomicgo/atomicgo/main/templates/readme.md -O .templates/readme.md | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: stable | ||
|
||
- name: Install Go tools | ||
run: | | ||
go install github.com/robertkrimen/godocdown/godocdown@latest | ||
go install github.com/princjef/gomarkdoc/cmd/gomarkdoc@latest | ||
go install github.com/caarlos0/svu@latest | ||
- name: Set up Git configuration | ||
run: | | ||
REPO_FULLNAME="${{ github.repository }}" | ||
echo "::group::Setup git" | ||
git config --global --add safe.directory /github/workspace | ||
echo "::notice::Login into git" | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "MarvinJWendt" | ||
echo "::notice::Ignore workflow files (we may not touch them)" | ||
git update-index --assume-unchanged .github/workflows/* | ||
- name: Generate README.md | ||
run: | | ||
echo "::group::Generate README.md" | ||
FILE=./.github/atomicgo/custom_readme | ||
INCLUDE_UNEXPORTED=./.github/atomicgo/include_unexported | ||
if test -f "$FILE"; then | ||
echo "::notice::.github/custom_readme is present. Not generating a new readme." | ||
else | ||
echo "::notice::Running Godocdown" | ||
$(go env GOPATH)/bin/godocdown -template ./.templates/readme.md >README.md | ||
echo "::notice::Running gomarkdoc" | ||
GOMARKDOC_FLAGS="--template-file example=./.templates/example.gotxt" | ||
if test -f "$INCLUDE_UNEXPORTED"; then | ||
GOMARKDOC_FLAGS+=" -u" | ||
fi | ||
$(go env GOPATH)/bin/gomarkdoc $GOMARKDOC_FLAGS --repository.url "https://github.com/${{ github.repository }}" --repository.default-branch main --repository.path / -e -o README.md . | ||
fi | ||
echo "::endgroup::" | ||
- name: Run custom CI system | ||
run: | | ||
echo "::group::Run custom CI system" | ||
echo "::notice::Counting unit tests" | ||
unittest_count=$(go test -v -p 1 ./... | tee /dev/tty | grep -c "RUN") | ||
echo "::notice::Replacing badge in README.md" | ||
sed -i 's|<img src="https://img.shields.io/badge/Unit_Tests-[^"]*-magenta?style=flat-square"|<img src="https://img.shields.io/badge/Unit_Tests-'$unittest_count'-magenta?style=flat-square"|g' README.md | ||
echo "::endgroup::" | ||
- name: Run go mod tidy | ||
run: | | ||
echo "::group::Run go mod tidy" | ||
git checkout go.mod # reset go.mod file | ||
git checkout go.sum # reset go.sum file | ||
go mod tidy | ||
echo "::endgroup::" | ||
- name: Stage and commit changes | ||
run: | | ||
echo "::group::Stage and commit changes" | ||
git add . | ||
git commit -m "docs: autoupdate" || true | ||
echo "::endgroup::" | ||
- name: Push changes | ||
run: | | ||
echo "::notice::Pushing changes to origin" | ||
git push -u origin main | ||
- name: Get current version | ||
id: current_version | ||
run: | | ||
echo "current_version=$(svu current)" >> $GITHUB_ENV | ||
echo "::notice::Current version is $(svu current)" | ||
- name: Calculate next version | ||
id: next_version | ||
run: | | ||
echo "next_version=$(svu next)" >> $GITHUB_ENV | ||
echo "::notice::Next version is $(svu next)" | ||
- name: Check if release is needed | ||
id: check_release | ||
run: | | ||
echo "release_needed=$( [ '${{ env.current_version }}' != '${{ env.next_version }}' ] && echo true || echo false )" >> $GITHUB_ENV | ||
- name: Create tag | ||
if: env.release_needed == 'true' | ||
run: | | ||
git tag -a ${{ env.next_version }} -m "Release v${{ env.next_version }}" | ||
git push origin ${{ env.next_version }} | ||
sleep 5 # sleep for 5 seconds to allow GitHub to process the tag | ||
- name: Release | ||
if: env.release_needed == 'true' | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
generate_release_notes: true | ||
tag_name: ${{ env.next_version }} | ||
|
||
- name: Tweet release | ||
if: env.release_needed == 'true' && !github.event.repository.private | ||
uses: Eomm/why-don-t-you-tweet@v1 | ||
with: | ||
tweet-message: | ||
"New ${{ github.event.repository.name }} release: ${{ env.next_version }} π | ||
Try it out: atomicgo.dev/${{ github.event.repository.name }} | ||
#go #golang #opensource #library #release #atomicgo" | ||
env: | ||
TWITTER_CONSUMER_API_KEY: ${{ secrets.TWITTER_CONSUMER_API_KEY }} | ||
TWITTER_CONSUMER_API_SECRET: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} | ||
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} | ||
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} |
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,42 @@ | ||
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
# β β | ||
# β IMPORTANT NOTE β | ||
# β β | ||
# β This file is synced with https://github.com/atomicgo/template β | ||
# β β | ||
# β Please apply all changes to the template repository β | ||
# β β | ||
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
|
||
name: Go | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: Test Go code | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: stable | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get dependencies | ||
run: go get -v -t -d ./... | ||
|
||
- name: Build | ||
run: go build -v . | ||
|
||
- name: Test | ||
run: go test -coverprofile="coverage.txt" -covermode=atomic -v -p 1 . | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 |
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,30 @@ | ||
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
# β β | ||
# β IMPORTANT NOTE β | ||
# β β | ||
# β This file is synced with https://github.com/atomicgo/template β | ||
# β β | ||
# β Please apply all changes to the template repository β | ||
# β β | ||
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
|
||
name: Code Analysis | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint: | ||
if: "!contains(github.event.head_commit.message, 'autoupdate')" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "stable" | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: latest |
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,36 @@ | ||
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
# β β | ||
# β IMPORTANT NOTE β | ||
# β β | ||
# β This file is synced with https://github.com/atomicgo/template β | ||
# β β | ||
# β Please apply all changes to the template repository β | ||
# β β | ||
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
|
||
name: Tweet release | ||
|
||
# Listen to the `release` event | ||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
tweet: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: Eomm/why-don-t-you-tweet@v1 | ||
# We don't want to tweet if the repository is not a public one | ||
if: ${{ !github.event.repository.private }} | ||
with: | ||
tweet-message: | ||
"New ${{ github.event.repository.name }} release: ${{ github.event.release.tag_name }}! π | ||
Try it out: atomicgo.dev/${{ github.event.repository.name }} | ||
#go #golang #opensource #library #release #atomicgo" | ||
env: | ||
TWITTER_CONSUMER_API_KEY: ${{ secrets.TWITTER_CONSUMER_API_KEY }} | ||
TWITTER_CONSUMER_API_SECRET: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} | ||
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} | ||
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} |
Oops, something went wrong.