Feat/actions (#2) #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: Build, Test, and Release | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- "v*" | |
paths-ignore: | |
- "**.md" | |
pull_request: | |
paths-ignore: | |
- "**.md" | |
jobs: | |
test: | |
name: Test on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.21" | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
- name: Install Caddy | |
run: | | |
curl -sS https://webi.sh/caddy | sh | |
echo "$HOME/.local/bin" >> $GITHUB_PATH | |
export PATH="$PATH:$HOME/.local/bin" | |
- name: Start Caddy | |
run: caddy run & | |
- name: Build localbase | |
run: go build -o localbase | |
- name: Start localbase | |
run: ./localbase start -d | |
- name: Create HTTP Server | |
run: | | |
echo "<html><body><h1>Hello, World!</h1></body></html>" > index.html | |
python3 -m http.server 5000 & | |
- name: Register Domain with LocalBase | |
run: ./localbase add webapp --port 5000 | |
continue-on-error: true | |
- name: Ping Registered Domain | |
run: | | |
curl -H "Host: webapp.local" http://localhost:5000 | |
- name: Stop LocalBase | |
run: ./localbase stop | |
build-and-release: | |
name: Build and Release | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.21" | |
- name: Run GoReleaser | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: goreleaser/goreleaser-action@v4 | |
with: | |
version: latest | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.SHIP_TOKEN }} |