From 8a60c5e0c44d28d2ff085e56299217e05e408df8 Mon Sep 17 00:00:00 2001 From: Lance Ball Date: Wed, 9 Sep 2020 22:24:09 -0400 Subject: [PATCH] feat(ci/cd): add release-please for automated release management This commit adds release-please as a github action, replacing the develop, main and releases actions. Now, with each commit to main, a PR is either created or updated with the contents of all changes since the last release. When this PR is landed, a tag and branch are created, and the build artifacts (binaries) are uploaded as part of a regular github release. A practical result of this landing will be that all work will subsequently happen on the `main` branch (aside from backport releases) and the `develop` branch will no longer be used. When this is landed on `main`, a release will not be created as per usual. Instead, a PR will be created with the contents of the changes since the last release. --- .github/workflows/{releases.yaml => ci.yaml} | 66 +++++++++++++++----- .github/workflows/develop.yaml | 41 ------------ .github/workflows/main.yaml | 27 -------- version.txt | 1 + 4 files changed, 50 insertions(+), 85 deletions(-) rename .github/workflows/{releases.yaml => ci.yaml} (61%) delete mode 100644 .github/workflows/develop.yaml delete mode 100644 .github/workflows/main.yaml create mode 100644 version.txt diff --git a/.github/workflows/releases.yaml b/.github/workflows/ci.yaml similarity index 61% rename from .github/workflows/releases.yaml rename to .github/workflows/ci.yaml index b31bd1445b..1ffd35f34a 100644 --- a/.github/workflows/releases.yaml +++ b/.github/workflows/ci.yaml @@ -1,22 +1,47 @@ -# Deploy artifacts for any pushes with a version tag (releases). -name: Releases +name: CI on: push: - tags: - - 'v*' + branches: + - "main" jobs: - build: - name: Build and Release Artifacts + build-and-publish: runs-on: ubuntu-latest steps: + - uses: GoogleCloudPlatform/release-please-action@v2.1.1 + id: release + with: + token: ${{ secrets.GITHUB_TOKEN }} + release-type: simple + + # Standard build tasks - uses: actions/checkout@v2 - uses: actions/setup-go@v2 - name: Test run: make test - name: Build run: make cross-platform + - name: Lint + run: make check + - name: Permissions + run: chmod a+x faas_*amd* + + # Upload all build artifacts whether it's a release or not + - uses: actions/upload-artifact@v2 + with: + name: OSX Binary + path: faas_darwin_amd64 + - uses: actions/upload-artifact@v2 + with: + name: Linux Binary + path: faas_linux_amd64 + - uses: actions/upload-artifact@v2 + with: + name: Windows Binary + path: faas_windows_amd64.exe + + # Build and push a latest image with each commit - name: Image run: make image - name: Push Image @@ -24,22 +49,16 @@ jobs: USER: ${{ secrets.QUAY_USER }} PASS: ${{ secrets.QUAY_TOKEN }} run: | - docker login -u "$USER" -p "$PASS" quay.io + docker login -u "$USER" -p "$PASS" quay.io make push && make latest + + # The following steps are only executed if this is a release - name: Compress Binaries + if: ${{ steps.release.outputs.release_created }} run: gzip faas_darwin_amd64 faas_linux_amd64 faas_windows_amd64.exe - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: false - name: Upload Darwin Binary uses: actions/upload-release-asset@v1 + if: ${{ steps.release.outputs.release_created }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -49,6 +68,7 @@ jobs: asset_content_type: application/x-gzip - name: Upload Linux Binary uses: actions/upload-release-asset@v1 + if: ${{ steps.release.outputs.release_created }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -58,6 +78,7 @@ jobs: asset_content_type: application/x-gzip - name: Upload Windows Binary uses: actions/upload-release-asset@v1 + if: ${{ steps.release.outputs.release_created }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -65,3 +86,14 @@ jobs: asset_path: ./faas_windows_amd64.exe.gz asset_name: faas_windows_amd64.exe.gz asset_content_type: application/x-gzip + - name: Create Release + id: create_release + if: ${{ steps.release.outputs.release_created }} + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false diff --git a/.github/workflows/develop.yaml b/.github/workflows/develop.yaml deleted file mode 100644 index c88786dec5..0000000000 --- a/.github/workflows/develop.yaml +++ /dev/null @@ -1,41 +0,0 @@ -# Build and test every push to the develop branch. -# -# NOTE: Seprate workflows per Branch -# The README contains a build status badge for each of the two primary branches -# main and develop. However, since the badge does not support unique labels -# (though it does support `?branch`) it appears to the reader as a duplicate -# status badge. We therefore separate the workflows entirely such that they -# have unique names: 'Main', 'Develop' -name: Develop - -on: - push: - branches: - - develop - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - - name: Test - run: make test - - name: Build - run: make cross-platform - - name: Lint - run: make check - - name: Permissions - run: chmod a+x faas_*amd* - - uses: actions/upload-artifact@v2 - with: - name: OSX Binary - path: faas_darwin_amd64 - - uses: actions/upload-artifact@v2 - with: - name: Linux Binary - path: faas_linux_amd64 - - uses: actions/upload-artifact@v2 - with: - name: Windows Binary - path: faas_windows_amd64.exe \ No newline at end of file diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml deleted file mode 100644 index 7323932235..0000000000 --- a/.github/workflows/main.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# Build and test every push to the main branch. -# -# NOTE: Seprate workflows per Branch -# The README contains a build status badge for each of the two primary branches -# main and develop. However, since the badge does not support unique labels -# (though it does support `?branch`) it appears to the reader as a duplicate -# status badge. We therefore separate the workflows entirely such that they -# have unique names: 'Main', 'Develop' -name: Main - -on: - push: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - - name: Test - run: make test - - name: Build - run: make build - - name: Lint - run: make check diff --git a/version.txt b/version.txt new file mode 100644 index 0000000000..b616048743 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.6.2