Skip to content

Commit

Permalink
workflows: add support for GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ayufan committed Feb 5, 2024
1 parent ede27ac commit d0382b6
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 10 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/build_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
on:
workflow_dispatch:
inputs:
VERSION:
description: 'Version to build'
required: false
type: string
TAG:
description: 'Tag name to use'
required: false
type: string

env:
VERSION: ${{ inputs.VERSION }}
TAG: ${{ inputs.TAG }}

jobs:
draft:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run github-create-draft
run: make github-create-draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker-build:
needs: [draft]
runs-on: ${{ matrix.runs_on }}
strategy:
matrix:
include:
- runs_on: [self-hosted, Linux, ARM64]
docker_arch: arm64v8
- runs_on: ubuntu-latest
docker_arch: amd64
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run dockerhub for ${{matrix.docker_arch}}
run: make ${{matrix.docker_arch}}-dockerhub
- name: Run deb for ${{matrix.docker_arch}}
run: make ${{matrix.docker_arch}}-deb
- name: Upload deb files
run: make github-upload-all
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

client-build:
needs: [draft]
runs-on: ${{ matrix.runs_on }}
strategy:
matrix:
include:
- runs_on: [self-hosted, Linux, ARM64]
docker_arch: arm64v8
- runs_on: ubuntu-latest
docker_arch: amd64
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Run client for ${{matrix.docker_arch}}
run: make ${{matrix.docker_arch}}-client
- name: Upload artifacts
run: make github-upload-all
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

prerelease:
runs-on: ubuntu-latest
needs: [client-build, docker-build]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run dockerhub-manifest
run: make dockerhub-manifest
- name: Run client for ${{matrix.docker_arch}}
run: make github-create-prerelease
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52 changes: 52 additions & 0 deletions .github/workflows/build_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
on:
push:
branches:
- '*'
paths-ignore:
- '*.md'
- .github/workflows/*.yaml
pull_request:
workflow_dispatch:
inputs:
VERSION:
description: 'Version to build'
required: false
type: string

env:
VERSION: ${{ inputs.VERSION }}

jobs:
docker-build:
runs-on: ${{ matrix.runs_on }}
strategy:
matrix:
include:
- runs_on: [self-hosted, Linux, ARM64]
docker_arch: arm64v8
- runs_on: ubuntu-latest
docker_arch: amd64
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Run docker-build for ${{matrix.docker_arch}}
run: make ${{matrix.docker_arch}}-docker-build

client-build:
runs-on: ${{ matrix.runs_on }}
strategy:
matrix:
include:
- runs_on: [self-hosted, Linux, ARM64]
docker_arch: arm64v8
- runs_on: ubuntu-latest
docker_arch: amd64
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Run client for ${{matrix.docker_arch}}
run: make ${{matrix.docker_arch}}-client
25 changes: 25 additions & 0 deletions .github/workflows/pre_to_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
workflow_dispatch:
TAG:
description: 'Tag name to use'
required: false
type: string

env:
TAG: ${{ inputs.TAG }}

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run dockerhub-latest-release
run: make github-latest-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 20 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
BUILD_ARCHS = amd64 arm64v8
CLIENT_BUILD_ARCHS = amd64 arm64v8
REGISTRY ?= ayufan/proxmox-backup-server
VERSION ?= $(shell ls versions | grep -E -v '.(tmp|debug)' | sort -V | tail -n 1)
SHELL = /usr/bin/env bash

TAG ?= $(VERSION)
ifeq (,$(VERSION))
VERSION := $(shell ls versions | grep -E -v '.(tmp|debug)' | sort -V | tail -n 1)
endif

ifeq (,$(TAG))
TAG := $(VERSION)
endif

ifneq (,$(wildcard .env.mk))
include .env.mk
Expand Down Expand Up @@ -142,22 +148,28 @@ release: dockerhub client deb

export GITHUB_USER ?= ayufan
export GITHUB_REPO ?= pve-backup-server-dockerfiles
GITHUB_RELEASE_BIN ?= go run github.com/github-release/github-release@latest

github-create-draft:
$(GITHUB_RELEASE_BIN) info -t $(TAG) || $(GITHUB_RELEASE_BIN) release -t $(TAG) --draft --description "$$(cat RELEASE.md)"

github-upload-all:
@set -e; for file in release/$(TAG)/*.tgz release/$(TAG)/*/*.deb; do \
@set -e; shopt -s nullglob; for file in release/$(TAG)/*.tgz release/$(TAG)/*/*.deb; do \
echo "Uploading $$file..."; \
github-release upload -t $(TAG) -R -n $$(basename $$file) -f $$file; \
$(GITHUB_RELEASE_BIN) upload -t $(TAG) -R -n $$(basename $$file) -f $$file; \
done

github-create-pre-release:
$(GITHUB_RELEASE_BIN) edit -t $(TAG) --pre-release --description "$$(cat RELEASE.md)"

github-pre-release:
rm -rf release/$(TAG)
make release
github-release --version || go install github.com/github-release/github-release@latest
git push
github-release info -t $(TAG) || github-release release -t $(TAG) --draft --description "$$(cat RELEASE.md)"
make github-create-draft
make github-upload-all
github-release edit -t $(TAG) --pre-release --description "$$(cat RELEASE.md)"
make github-create-pre-release

github-latest-release:
github-release edit -t $(TAG) --description "$$(cat RELEASE.md)"
make dockerhub-latest-release
$(GITHUB_RELEASE_BIN) edit -t $(TAG) --description "$$(cat RELEASE.md)"
4 changes: 2 additions & 2 deletions versions/v3.1.2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ RUN apt-get -y update && \

RUN wget https://static.rust-lang.org/rustup/rustup-init.sh && \
chmod +x rustup-init.sh && \
./rustup-init.sh -y --default-toolchain nightly
./rustup-init.sh -y --default-toolchain stable

ENV RUSTUP_TOOLCHAIN=nightly
ENV RUSTUP_TOOLCHAIN=stable

WORKDIR /src

Expand Down

0 comments on commit d0382b6

Please sign in to comment.