From baf7abc9a69a69aed2f6dd61700819eadcd7daf9 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Tue, 15 Dec 2020 13:38:23 +0100 Subject: [PATCH] add release workflow --- .github/workflows/lint.yml | 4 +-- .github/workflows/release.yml | 57 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 4 +-- Makefile | 4 ++- 4 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 148dd6f8..9c8ea02f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,9 +2,9 @@ name: lint on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] jobs: lint: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..299c1283 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +name: release + +on: + push: + tags: + - 'v*' + +jobs: + github: + name: github + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - run: make release + + - uses: actions/create-release@v1 + id: create_release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + + - uses: actions/github-script@v2 + env: + RELEASE_ID: ${{ steps.create_release.outputs.id }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const fs = require('fs').promises; + const { repo: { owner, repo } } = context; + + for (let file of await fs.readdir('./release/')) { + await github.repos.uploadReleaseAsset({ + owner, + repo, + release_id: process.env.RELEASE_ID, + name: file, + data: await fs.readFile(`./release/${file}`) + }); + } + + dockerhub: + name: dockerhub + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - run: make dockerhub + env: + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5114cea0..4f705c69 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,9 +2,9 @@ name: test on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] jobs: test: diff --git a/Makefile b/Makefile index b66c3601..8ca9b659 100644 --- a/Makefile +++ b/Makefile @@ -124,7 +124,7 @@ export DOCKERFILE_RELEASE release: echo "$$DOCKERFILE_RELEASE" | docker build . -f - -t temp \ - && docker run --rm -it -v $(PWD):/out \ + && docker run --rm -v $(PWD):/out \ temp sh -c "rm -rf /out/release && cp -r /s/release /out/" release-nodocker: @@ -176,6 +176,8 @@ dockerhub: $(eval export DOCKER_CLI_EXPERIMENTAL=enabled) $(eval VERSION := $(shell git describe --tags)) + docker login -u $(DOCKER_USER) -p $(DOCKER_PASSWORD) + docker buildx rm builder 2>/dev/null || true rm -rf $$HOME/.docker/manifests/* docker buildx create --name=builder --use