fix(docs): fix docs and make a release #92
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: Build and Release | |
on: | |
push: | |
branches: | |
- master | |
permissions: | |
contents: write # to create release commit (google-github-actions/release-please-action) | |
pull-requests: write # to create release PR (google-github-actions/release-please-action) | |
jobs: | |
build: | |
services: | |
postgres: | |
image: postgres:16 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: db_test | |
ports: | |
- 5432/tcp | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: google-github-actions/release-please-action@v3 | |
id: release | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
release-type: go | |
- uses: actions/checkout@v4 | |
- name: Set up Go 1.22 | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ^1.22 | |
cache: true | |
id: go | |
- name: setup env | |
run: | | |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV | |
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH | |
shell: bash | |
- name: Generate | |
run: | | |
echo "GH_TAG=$(echo $GITHUB_REF | awk -F / '{print $3}')" >> $GITHUB_ENV | |
go install github.com/vektra/mockery/v2@v2.42.0 | |
go generate ./... | |
- name: Test | |
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Build | |
if: ${{ steps.release.outputs.release_created }} | |
env: | |
GOARCH: amd64 | |
CGO_ENABLED: 1 | |
GOOS: linux | |
run: | | |
make release | |
chmod +x up-pp-api | |
- uses: dsaltares/fetch-gh-release-asset@master | |
if: ${{ steps.release.outputs.release_created }} | |
with: | |
repo: "PromptPal/web" | |
file: "dist.zip" | |
target: "dist.zip" | |
token: ${{ secrets.GH_PERSONAL_TOKEN }} | |
- uses: montudor/action-zip@v1 | |
if: ${{ steps.release.outputs.release_created }} | |
with: | |
args: unzip -qq dist.zip -d public | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
if: ${{ steps.release.outputs.release_created }} | |
with: | |
images: annatarhe/prompt-pal | |
tags: ${{ steps.release.outputs.tag_name }} | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
if: ${{ steps.release.outputs.release_created }} | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
if: ${{ steps.release.outputs.release_created }} | |
with: | |
context: . | |
file: ./Dockerfile | |
push: ${{ github.event_name != 'pull_request' && steps.release.outputs.release_created }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |