doc(CHANGELOG): v0.1.1 (#12) #2
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
name: release | |
on: | |
push: | |
branches: [main] | |
paths: ["CHANGELOG.md"] | |
permissions: write-all | |
jobs: | |
test: | |
uses: ./.github/workflows/ci.yaml | |
release: | |
needs: | |
- test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.goversion }} | |
cache: true | |
cache-dependency-path: go.sum | |
- name: Setup mockgen | |
run: | | |
go install go.uber.org/mock/mockgen@latest | |
- name: Go Generate | |
run: | | |
go mod tidy | |
go generate ./... | |
git diff --exit-code | |
- name: Unit Test | |
run: | | |
TARGET=$(go list ./... | grep -v "mock") | |
go test $TARGET -v -coverpkg=$TARGET -coverprofile=coverage.out | |
- name: Upload unit test coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: coverage.out | |
fail_ci_if_error: false | |
verbose: true | |
- name: Extract Version | |
id: versioning | |
run: | | |
VERSION="v$(sed -n 's/##\s\([0-9.]*\)\s.*/\1/p' CHANGELOG.md | head -1)" | |
echo ::set-output name=version::$VERSION | |
- name: Extract changes from prev version | |
run: | | |
git fetch --prune --unshallow | |
PRETAG=$(git tag --sort -v:refname | head -1) | |
CURRENTTAG=${{ steps.versioning.outputs.version }} | |
echo "## What's Changed in ${CURRENTTAG}" > diff-changelog.txt | |
if [ -z "$PRETAG" ] | |
then | |
cat CHANGELOG.md | sed -e 's/#\sChangelog.*//g' | sed -e 's/##\s[0-9.]*\s.*//g' | sed -e '/^$/d' >> diff-changelog.txt | |
else | |
git diff $PRETAG..${{ github.sha }} -- CHANGELOG.md | grep -E '^\+' | grep -v '+++' | sed -e 's/^\+//g' | sed -e 's/##\s[0-9.]*\s.*//g' | sed -e '/^$/d' >> diff-changelog.txt | |
echo "" >> diff-changelog.txt | |
echo "**Full Changelog**: https://github.com/miyamo2/sqldav/compare/${PRETAG}...${CURRENTTAG}" >> diff-changelog.txt | |
fi | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ steps.versioning.outputs.version }} | |
generate_release_notes: false | |
body_path: diff-changelog.txt |