Merge pull request #17 from RyaWcksn/master #35
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 workflow will build a golang project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | |
name: Go | |
on: | |
push: | |
branches: [ "release/*" ] | |
jobs: | |
build: | |
permissions: | |
contents: write | |
issues: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
# Explicitly setting an LTS version of Node.js | |
node-version: 20 | |
- name: Go Format | |
run: gofmt -s -w . && git diff --exit-code | |
- name: Go Vet | |
run: go vet ./... | |
- name: Go Tidy | |
run: go mod tidy && git diff --exit-code | |
- name: Go Mod | |
run: go mod download | |
- name: Go Mod Verify | |
run: go mod verify | |
- name: Build | |
run: go build -v ./... | |
- name: Test | |
run: go test -v -count=1 -race -shuffle=on -coverprofile=cov.txt ./... | |
- name: Upload Coverage | |
uses: codecov/codecov-action@v3 | |
continue-on-error: true | |
with: | |
token: ${{secrets.CODECOV_TOKEN}} | |
file: ./cov.txt | |
fail_ci_if_error: false | |
# - name: Run tests and calculate coverage | |
# run: | | |
# go test ./... -coverprofile=coverage.out | |
# go tool cover -func=coverage.out > coverage.txt | |
# shell: bash | |
# - name: Check coverage | |
# run: ./check_coverage.sh | |
# shell: bash | |
- name: Release | |
run: npx semantic-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate Release Notes | |
run: | | |
VERSION=$(npx semantic-release-cli version) | |
echo "# Release Notes v.${VERSION}" > "v.${VERSION}.md" | |
npx semantic-release-cli changelog >> "v.${VERSION}.md" | |
echo "Release version: $VERSION" >> "v.${VERSION}.md" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Commit and Push Release Notes | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
git add "v.${VERSION}.md" | |
git commit -m "chore(release): v.${{ steps.release.outputs.version }} release notes [skip ci]" | |
git push | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- | |
name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- | |
name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
tags: ryawcksn/ecommerce:latest |