diff --git a/.github/workflows/build_release.yaml b/.github/workflows/build_release.yaml index 17ea1b7..22887f3 100644 --- a/.github/workflows/build_release.yaml +++ b/.github/workflows/build_release.yaml @@ -1,8 +1,17 @@ on: - push: - tags: - - '*' workflow_dispatch: + 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: @@ -14,11 +23,15 @@ jobs: run: make github-create-draft docker-build: - runs-on: ubuntu-latest needs: [draft] + runs-on: ${{ matrix.runs_on }} strategy: matrix: - docker_arch: [amd64, arm64v8] + include: + - runs_on: [self-hosted, Linux, ARM64] + docker_arch: arm64v8 + - runs_on: ubuntu-latest + docker_arch: amd64 steps: - name: Checkout uses: actions/checkout@v3 @@ -32,11 +45,15 @@ jobs: run: make github-upload-all client-build: - runs-on: ubuntu-latest needs: [draft] + runs-on: ${{ matrix.runs_on }} strategy: matrix: - docker_arch: [amd64, arm64v8] + include: + - runs_on: [self-hosted, Linux, ARM64] + docker_arch: arm64v8 + - runs_on: ubuntu-latest + docker_arch: amd64 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/build_test.yaml b/.github/workflows/build_test.yaml index 6dcd615..8c0fe68 100644 --- a/.github/workflows/build_test.yaml +++ b/.github/workflows/build_test.yaml @@ -4,13 +4,21 @@ on: - '*' paths-ignore: - '*.md' + - .github/workflows/*.yaml pull_request: workflow_dispatch: + VERSION: + description: 'Version to build' + required: false + type: string + +env: + VERSION: ${{ inputs.VERSION }} jobs: docker-build: runs-on: ${{ matrix.runs_on }} - strategy: &build_variants + strategy: matrix: include: - runs_on: [self-hosted, Linux, ARM64] @@ -27,7 +35,13 @@ jobs: client-build: runs-on: ${{ matrix.runs_on }} - strategy: *build_variants + 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 diff --git a/.github/workflows/pre_to_release.yaml b/.github/workflows/pre_to_release.yaml new file mode 100644 index 0000000..06871ef --- /dev/null +++ b/.github/workflows/pre_to_release.yaml @@ -0,0 +1,20 @@ +on: + workflow_dispatch: + TAG: + description: 'Tag name to use' + required: false + type: string + +env: + TAG: ${{ inputs.TAG }} + +jobs: + release: + runs-on: ubuntu-latest + needs: [client-build, docker-build] + if: inputs.TAG + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Run dockerhub-latest-release + run: make github-latest-release diff --git a/Makefile b/Makefile index 584936d..3676899 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,14 @@ 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) -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 @@ -143,18 +148,20 @@ release: dockerhub client deb export GITHUB_USER ?= ayufan export GITHUB_REPO ?= pve-backup-server-dockerfiles -github-create-draft: +github-release: github-release --version || go install github.com/github-release/github-release@latest + +github-create-draft: github-release git push github-release info -t $(TAG) || github-release release -t $(TAG) --draft --description "$$(cat RELEASE.md)" -github-upload-all: +github-upload-all: github-release @set -e; for file in release/$(TAG)/*.tgz release/$(TAG)/*/*.deb; do \ echo "Uploading $$file..."; \ github-release upload -t $(TAG) -R -n $$(basename $$file) -f $$file; \ done -github-create-pre-release: +github-create-pre-release: github-release github-release edit -t $(TAG) --pre-release --description "$$(cat RELEASE.md)" github-pre-release: @@ -164,6 +171,6 @@ github-pre-release: make github-upload-all make github-create-pre-release -github-latest-release: - github-release edit -t $(TAG) --description "$$(cat RELEASE.md)" +github-latest-release: github-release make dockerhub-latest-release + github-release edit -t $(TAG) --description "$$(cat RELEASE.md)"