fix(ci): trigger ci when yaml is edited #175
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: Go CI | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- '*' | |
branches: | |
- 'main' | |
paths: | |
- '**.go' | |
- '**.c' | |
- '**.h' | |
- 'Dockerfile*' | |
- '.github/workflows/main.yaml' | |
pull_request: | |
branches: | |
- 'main' | |
jobs: | |
lint: | |
name: Lint fc2-live-dl-go | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download build-essential | |
run: | | |
sudo apt update -y | |
sudo apt install -y build-essential libavformat-dev libavcodec-dev libavutil-dev | |
- uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
cache-dependency-path: go.sum | |
- name: Download all Go modules | |
run: | | |
go mod download | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: latest | |
args: --timeout 5m | |
test: | |
name: Test fc2-live-dl-go | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download build-essential | |
run: | | |
sudo apt update -y | |
sudo apt install -y build-essential libavformat-dev libavcodec-dev libavutil-dev | |
- uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
cache-dependency-path: go.sum | |
- name: Download all Go modules | |
run: | | |
go mod download | |
- name: test | |
run: go test -v -race -covermode=atomic -tags=unit -timeout=30s ./... | |
build-export-static: | |
name: Build and export fc2-live-dl-go static Docker | |
runs-on: ubuntu-latest | |
needs: [lint, test] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Context for Buildx | |
run: | | |
docker context create builders | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: latest | |
endpoint: builders | |
- name: Login to GitHub Container Registry | |
if: startsWith(github.ref, 'refs/tags') | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get the oci compatible version | |
if: startsWith(github.ref, 'refs/tags') | |
id: get_version | |
run: | | |
echo "VERSION=$(echo ${GITHUB_REF#refs/*/})" >> $GITHUB_OUTPUT | |
echo "OCI_VERSION=$(echo ${GITHUB_REF#refs/*/} | sed 's/+/-/g' | sed -E 's/v(.*)/\1/g' )" >> $GITHUB_OUTPUT | |
- name: Build export | |
uses: docker/build-push-action@v5 | |
if: ${{ ! startsWith(github.ref, 'refs/tags') }} | |
with: | |
file: Dockerfile.static | |
platforms: linux/amd64,linux/arm64,linux/riscv64 | |
push: false | |
tags: darkness4/fc2-live-dl-go:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Build and export | |
if: startsWith(github.ref, 'refs/tags') | |
uses: docker/build-push-action@v5 | |
with: | |
file: Dockerfile.static | |
platforms: linux/amd64,linux/arm64,linux/riscv64 | |
push: true | |
build-args: | | |
VERSION=${{ steps.get_version.outputs.VERSION }} | |
tags: | | |
ghcr.io/darkness4/fc2-live-dl-go:latest | |
ghcr.io/darkness4/fc2-live-dl-go:dev | |
ghcr.io/darkness4/fc2-live-dl-go:${{ steps.get_version.outputs.OCI_VERSION }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Build and export dev | |
if: github.event_name == 'workflow_dispatch' | |
uses: docker/build-push-action@v5 | |
with: | |
file: Dockerfile.static | |
platforms: linux/amd64,linux/arm64,linux/riscv64 | |
push: true | |
build-args: | | |
VERSION=dev | |
tags: | | |
ghcr.io/darkness4/fc2-live-dl-go:dev | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-windows: | |
name: Test Build fc2-live-dl-go static windows binaries | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Context for Buildx | |
run: | | |
docker context create builders | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: latest | |
endpoint: builders | |
- name: Build | |
uses: docker/build-push-action@v5 | |
with: | |
file: Dockerfile.static-windows | |
platforms: linux/amd64 | |
push: false | |
tags: darkness4/fc2-live-dl-go:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-darwin: | |
name: Test Build fc2-live-dl-go darwin binaries | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Context for Buildx | |
run: | | |
docker context create builders | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: latest | |
endpoint: builders | |
- name: Build Darwin | |
uses: docker/build-push-action@v5 | |
with: | |
file: Dockerfile.darwin | |
platforms: linux/amd64,linux/arm64 | |
push: false | |
tags: darkness4/fc2-live-dl-go:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |