From e0b14a4514ab3cd614b61e10e4b05aab51006bab Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 31 Mar 2021 23:55:52 +0100 Subject: [PATCH] Add CI with GitHub Actions --- .github/workflows/release.yml | 48 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 36 ++++++++++++++++++++++++++ .releaserc.yml | 11 ++++++++ 3 files changed, 95 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml create mode 100644 .releaserc.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2048d0f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: Release + +on: + push: + tags: + - "*" + +jobs: + docker: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + token: ${{ secrets.API_GITHUB_TOKEN }} + + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v2 + with: + images: juanluisbaptiste/postfix + tags: | + type=semver,pattern={{major}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}}.{{minor}}.{{patch}} + type=semver,pattern={{version}} + alpine + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + push: true + platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..08bbb51 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,36 @@ +name: Test + +on: + push: + branches: [master, develop] + pull_request: + branches: [master, develop] + +jobs: + build: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout with token + if: github.event_name != 'pull_request' + uses: actions/checkout@v2 + with: + token: ${{ secrets.API_GITHUB_TOKEN }} + + - name: Checkout without token + if: github.event_name == 'pull_request' + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Docker Build Test + run: docker buildx build --load --tag test:test --file ./Dockerfile ./ + + - name: Version + if: github.event_name != 'pull_request' + uses: cycjimmy/semantic-release-action@v2.5.3 + with: + semantic_version: 17.4 + env: + GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }} diff --git a/.releaserc.yml b/.releaserc.yml new file mode 100644 index 0000000..65eeeeb --- /dev/null +++ b/.releaserc.yml @@ -0,0 +1,11 @@ +--- +branches: + - name: master + - name: develop + prerelease: true +plugins: + - "@semantic-release/commit-analyzer" + - "@semantic-release/release-notes-generator" + - - "@semantic-release/github" + - successComment: false + failComment: false