error-pages/.github/workflows/release.yml

105 lines
4.1 KiB
YAML
Raw Normal View History

2024-07-03 14:12:13 +00:00
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
# docs: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: 🚀 Release
2020-07-08 11:12:21 +00:00
on:
release: # Docs: <https://git.io/JeBz1#release-event-release>
types: [published]
jobs:
2021-09-29 15:38:50 +00:00
build:
name: Build for ${{ matrix.os }} (${{ matrix.arch }})
2023-02-23 17:50:20 +00:00
runs-on: ubuntu-latest
2021-09-29 15:38:50 +00:00
strategy:
fail-fast: false
matrix:
2024-07-03 14:12:13 +00:00
os: [linux, darwin, windows] # freebsd
arch: [amd64, arm64] # 386
2020-07-08 11:12:21 +00:00
steps:
- uses: actions/checkout@v4
2024-07-03 14:12:13 +00:00
- {uses: actions/setup-go@v5, with: {go-version-file: go.mod}}
- {uses: gacts/github-slug@v1, id: slug}
2024-07-03 14:12:13 +00:00
- id: values
run: echo "binary-name=error-pages-${{ matrix.os }}-${{ matrix.arch }}`[ ${{ matrix.os }} = 'windows' ] && echo '.exe'`" >> $GITHUB_OUTPUT
- env:
2021-09-29 15:38:50 +00:00
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: 0
2023-02-23 17:50:20 +00:00
LDFLAGS: -s -w -X gh.tarampamp.am/error-pages/internal/version.version=${{ steps.slug.outputs.version }}
2021-09-29 15:38:50 +00:00
run: go build -trimpath -ldflags "$LDFLAGS" -o "./${{ steps.values.outputs.binary-name }}" ./cmd/error-pages/
2024-07-03 14:12:13 +00:00
- uses: svenstaro/upload-release-action@v2
2020-07-08 11:12:21 +00:00
with:
2021-09-29 15:38:50 +00:00
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.values.outputs.binary-name }}
asset_name: ${{ steps.values.outputs.binary-name }}
tag: ${{ github.ref }}
2020-07-08 11:12:21 +00:00
2024-07-03 14:12:13 +00:00
- if: matrix.os == 'linux' && matrix.arch == 'amd64'
run: mkdir ./out && ./${{ steps.values.outputs.binary-name }} build --index --target-dir ./out
- if: matrix.os == 'linux' && matrix.arch == 'amd64'
uses: actions/upload-artifact@v4
with:
name: error-pages-static
path: out/
if-no-files-found: error
retention-days: 1
- if: matrix.os == 'linux' && matrix.arch == 'amd64'
working-directory: ./out
run: zip -r ./../templates.zip .
- if: matrix.os == 'linux' && matrix.arch == 'amd64'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: templates.zip
asset_name: error-pages-static.zip
tag: ${{ github.ref }}
demo:
name: Update the demo (GitHub Pages)
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/download-artifact@v4
with:
name: error-pages-static
path: .artifact
- uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./.artifact
2020-07-08 11:12:21 +00:00
docker-image:
2024-07-03 14:12:13 +00:00
name: Build the docker image
2023-02-23 17:50:20 +00:00
runs-on: ubuntu-latest
2020-07-08 11:12:21 +00:00
steps:
- uses: actions/checkout@v4
- {uses: gacts/github-slug@v1, id: slug}
2024-07-03 14:12:13 +00:00
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
2021-07-20 10:05:06 +00:00
with:
username: ${{ secrets.DOCKER_LOGIN }}
password: ${{ secrets.DOCKER_PASSWORD }}
2024-07-03 14:12:13 +00:00
- uses: docker/login-action@v3
2021-07-20 10:05:06 +00:00
with:
registry: ghcr.io
username: ${{ github.actor }}
2022-05-12 12:20:02 +00:00
password: ${{ secrets.GITHUB_TOKEN }}
2024-07-03 14:12:13 +00:00
- uses: docker/build-push-action@v6
2021-09-29 15:38:50 +00:00
with:
context: .
file: Dockerfile
push: true
2024-07-03 14:12:13 +00:00
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
2021-09-29 15:38:50 +00:00
build-args: "APP_VERSION=${{ steps.slug.outputs.version }}"
2024-07-05 08:56:55 +00:00
tags:
tarampampam/error-pages:latest
tarampampam/error-pages:${{ steps.slug.outputs.version }}
tarampampam/error-pages:${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}
tarampampam/error-pages:${{ steps.slug.outputs.version-major }}
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:latest
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:${{ steps.slug.outputs.version }}
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:${{ steps.slug.outputs.version-major }}