diff --git a/.github/workflows/build_release.yaml b/.github/workflows/build_release.yaml new file mode 100644 index 0000000..1affe7e --- /dev/null +++ b/.github/workflows/build_release.yaml @@ -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 }} diff --git a/.github/workflows/build_test.yaml b/.github/workflows/build_test.yaml new file mode 100644 index 0000000..37a980e --- /dev/null +++ b/.github/workflows/build_test.yaml @@ -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 diff --git a/.github/workflows/pre_to_release.yaml b/.github/workflows/pre_to_release.yaml new file mode 100644 index 0000000..04bbcea --- /dev/null +++ b/.github/workflows/pre_to_release.yaml @@ -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 }} diff --git a/Makefile b/Makefile index 778f70b..fc6bea7 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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)" diff --git a/versions/v3.1.2/Dockerfile b/versions/v3.1.2/Dockerfile index 662ee8b..aeee7ee 100644 --- a/versions/v3.1.2/Dockerfile +++ b/versions/v3.1.2/Dockerfile @@ -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