forked from massivebox/ecodash
124 lines
3.1 KiB
YAML
124 lines
3.1 KiB
YAML
|
name: CI Pipeline
|
||
|
|
||
|
on:
|
||
|
push:
|
||
|
branches:
|
||
|
- master
|
||
|
tags:
|
||
|
- 'v*'
|
||
|
|
||
|
jobs:
|
||
|
|
||
|
build:
|
||
|
runs-on: ubuntu-22.04
|
||
|
steps:
|
||
|
|
||
|
- name: Set up Go
|
||
|
uses: actions/setup-go@v3
|
||
|
with:
|
||
|
go-version: '1.22'
|
||
|
|
||
|
- name: Checkout code
|
||
|
uses: actions/checkout@v3
|
||
|
|
||
|
- name: Build
|
||
|
run: |
|
||
|
go mod tidy
|
||
|
echo Building for linux/amd64...
|
||
|
GOOS=linux GOARCH=amd64 go build -o ecodash_x86 src/main/main.go
|
||
|
echo Building for linux/arm...
|
||
|
GOOS=linux GOARCH=arm go build -o ecodash_arm src/main/main.go
|
||
|
|
||
|
- name: Stash artifacts
|
||
|
uses: actions/upload-artifact@v3
|
||
|
with:
|
||
|
path: |
|
||
|
ecodash_x86
|
||
|
ecodash_arm
|
||
|
|
||
|
build-and-push-docker:
|
||
|
runs-on: ubuntu-22.04
|
||
|
needs: build
|
||
|
steps:
|
||
|
|
||
|
- name: Checkout
|
||
|
uses: actions/checkout@v4
|
||
|
|
||
|
- name: Docker meta
|
||
|
id: meta
|
||
|
uses: https://github.com/docker/metadata-action@v5
|
||
|
with:
|
||
|
images: git.massivebox.net/massivebox/ecodash
|
||
|
tags: |
|
||
|
type=ref,event=branch
|
||
|
type=semver,pattern={{version}}
|
||
|
type=semver,pattern=v{{major}}
|
||
|
type=semver,pattern={{major}}.{{minor}}
|
||
|
|
||
|
- name: Install QEMU
|
||
|
run: sudo apt-get update && sudo apt-get install -y qemu-user-static
|
||
|
- name: Set up Docker Buildx
|
||
|
uses: docker/setup-buildx-action@v3
|
||
|
- name: Login to Docker Hub
|
||
|
uses: docker/login-action@v3
|
||
|
with:
|
||
|
registry: git.massivebox.net
|
||
|
username: ${{ github.actor }}
|
||
|
password: ${{ secrets.FORGE_TOKEN }}
|
||
|
|
||
|
- name: Download artifacts
|
||
|
uses: actions/download-artifact@v3
|
||
|
with:
|
||
|
name: artifact
|
||
|
- name: Move dockerfile
|
||
|
run: mv .forgejo/workflows/Dockerfile Dockerfile
|
||
|
|
||
|
- name: Build and push
|
||
|
uses: docker/build-push-action@v5
|
||
|
with:
|
||
|
context: .
|
||
|
platforms: linux/amd64,linux/arm64
|
||
|
push: true
|
||
|
tags: ${{ steps.meta.outputs.tags }}
|
||
|
|
||
|
publish-executables:
|
||
|
runs-on: ubuntu-22.04
|
||
|
needs: build
|
||
|
steps:
|
||
|
|
||
|
- name: Checkout code
|
||
|
uses: actions/checkout@v3
|
||
|
|
||
|
- name: Download artifacts
|
||
|
uses: actions/download-artifact@v3
|
||
|
with:
|
||
|
name: artifact
|
||
|
|
||
|
- name: Prepare build artifacts
|
||
|
run: |
|
||
|
mkdir release
|
||
|
mv ecodash_x86 ecodash
|
||
|
zip -r release/ecodash-x86.zip templates ecodash
|
||
|
mv ecodash_arm ecodash
|
||
|
zip -r release/ecodash-arm.zip templates ecodash
|
||
|
|
||
|
- name: Upload artifacts to CI
|
||
|
uses: actions/upload-artifact@v3
|
||
|
with:
|
||
|
path: |
|
||
|
ecodash_x86
|
||
|
ecodash_arm
|
||
|
templates
|
||
|
overwrite: true
|
||
|
|
||
|
- name: Create release
|
||
|
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
||
|
uses: actions/forgejo-release@v1
|
||
|
with:
|
||
|
direction: upload
|
||
|
url: https://git.massivebox.net
|
||
|
repo: massivebox/ecodash
|
||
|
release-dir: release
|
||
|
tag: ${{ github.ref_name }}
|
||
|
token: ${{ secrets.FORGE_TOKEN }}
|