diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c6c1431..cfafe75 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,10 +13,21 @@ # limitations under the License. name: build -on: ['push'] +on: + create: + push: + branches: + - master + - 'v*' + paths-ignore: + - 'docs/**' + - 'changelogs/**' + - 'deploy/helm/**' + - 'CHANGELOG.md' jobs: lint: + if: ${{ (github.event.ref_type == 'branch') }} # to ignore builds on release runs-on: ubuntu-latest steps: - name: Checkout @@ -33,6 +44,7 @@ jobs: unit-test: + if: ${{ (github.event.ref_type == 'branch') }} # to ignore builds on release runs-on: ubuntu-latest steps: - name: Checkout @@ -97,6 +109,12 @@ jobs: - name: Checkout uses: actions/checkout@v2 + - name: Set Image Org + # sets the default IMAGE_ORG to openebs + run: | + [ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}} + echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV + - name: Set Tag run: | BRANCH="${GITHUB_REF##*/}" @@ -107,10 +125,28 @@ jobs: echo "TAG=${CI_TAG}" >> $GITHUB_ENV echo "BRANCH=${BRANCH}" >> $GITHUB_ENV + - name: Set Build Date + id: date + run: | + echo "::set-output name=DATE::$(date -u +'%Y-%m-%dT%H:%M:%S%Z')" + + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + # add each registry to which the image needs to be pushed here + images: | + ${{ env.IMAGE_ORG }}/zfs-driver + quay.io/${{ env.IMAGE_ORG }}/zfs-driver + tag-latest: false + tag-custom-only: true + tag-custom: | + ${{ env.TAG }} + - name: Print Tag info run: | echo "BRANCH: ${BRANCH}" - echo "TAG: ${TAG}" + echo "${{ steps.docker_meta.outputs.tags }}" - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -129,9 +165,24 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to Quay + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_TOKEN }} + - name: Build & Push Image - env: - IMAGE_ORG: ${{ secrets.IMAGE_ORG}} - run: | - make docker.buildx.csi-driver - make buildx.push.csi-driver + uses: docker/build-push-action@v2 + with: + context: . + file: ./buildscripts/zfs-driver/zfs-driver.Dockerfile + push: true + platforms: linux/amd64, linux/arm64 + tags: | + ${{ steps.docker_meta.outputs.tags }} + build-args: | + DBUILD_DATE=${{ steps.date.outputs.DATE }} + DBUILD_REPO_URL=https://github.com/openebs/zfs-localpv + DBUILD_SITE_URL=https://openebs.io + BRANCH=${{ env.BRANCH }} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index a228b6d..6fdacb2 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -18,6 +18,9 @@ on: pull_request: paths-ignore: - 'deploy/helm/**' + - 'docs/**' + - 'changelogs/**' + - 'CHANGELOG.md' branches: # on pull requests to master and release branches - master @@ -116,7 +119,12 @@ jobs: with: version: v0.4.2 - - name: Build Image - env: - IMG_RESULT: cache - run: make docker.buildx.csi-driver + - name: Build + uses: docker/build-push-action@v2 + with: + context: . + file: ./buildscripts/zfs-driver/zfs-driver.Dockerfile + push: false + platforms: linux/amd64, linux/arm64 + tags: | + openebs/zfs-driver:ci diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1bf67ce..4b062e9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,9 @@ name: release on: - push: + release: + types: + - "created" tags: - 'v*' @@ -24,6 +26,12 @@ jobs: steps: - name: Checkout uses: actions/checkout@v1 + + - name: Set Image Org + # sets the default IMAGE_ORG to openebs + run: | + [ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}} + echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV - name: Set Tag run: | @@ -31,8 +39,26 @@ jobs: echo "TAG=${TAG}" >> $GITHUB_ENV echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV + - name: Set Build Date + id: date + run: | + echo "::set-output name=DATE::$(date -u +'%Y-%m-%dT%H:%M:%S%Z')" + + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + # add each registry to which the image needs to be pushed here + images: | + ${{ env.IMAGE_ORG }}/zfs-driver + quay.io/${{ env.IMAGE_ORG }}/zfs-driver + tag-latest: true + tag-semver: | + {{version}} + - name: Print Tag info run: | + echo "${{ steps.docker_meta.outputs.tags }}" echo "RELEASE TAG: ${RELEASE_TAG}" - name: Set up QEMU @@ -51,10 +77,25 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to Quay + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_TOKEN }} - name: Build & Push Image - env: - IMAGE_ORG: ${{ secrets.IMAGE_ORG}} - run: | - make docker.buildx.csi-driver - make buildx.push.csi-driver + uses: docker/build-push-action@v2 + with: + context: . + file: ./buildscripts/zfs-driver/zfs-driver.Dockerfile + push: true + platforms: linux/amd64, linux/arm64 + tags: | + ${{ steps.docker_meta.outputs.tags }} + build-args: | + DBUILD_DATE=${{ steps.date.outputs.DATE }} + DBUILD_REPO_URL=https://github.com/openebs/zfs-localpv + DBUILD_SITE_URL=https://openebs.io + RELEASE_TAG=${{ env.RELEASE_TAG }} diff --git a/buildscripts/generate-manifests.sh b/buildscripts/generate-manifests.sh index d591449..d92a1e3 100755 --- a/buildscripts/generate-manifests.sh +++ b/buildscripts/generate-manifests.sh @@ -46,6 +46,7 @@ echo ' cat deploy/yamls/zfs.openebs.io_zfsvolumes.yaml >> deploy/yamls/zfsvolume-crd.yaml rm deploy/yamls/zfs.openebs.io_zfsvolumes.yaml +cp deploy/yamls/zfsvolume-crd.yaml deploy/helm/charts/crds/zfsvolume.yaml echo ' @@ -61,7 +62,7 @@ echo ' cat deploy/yamls/zfs.openebs.io_zfssnapshots.yaml >> deploy/yamls/zfssnapshot-crd.yaml rm deploy/yamls/zfs.openebs.io_zfssnapshots.yaml - +cp deploy/yamls/zfssnapshot-crd.yaml deploy/helm/charts/crds/zfssnapshot.yaml echo ' @@ -77,7 +78,7 @@ echo ' cat deploy/yamls/zfs.openebs.io_zfsbackups.yaml >> deploy/yamls/zfsbackup-crd.yaml rm deploy/yamls/zfs.openebs.io_zfsbackups.yaml - +cp deploy/yamls/zfsbackup-crd.yaml deploy/helm/charts/crds/zfsbackup.yaml echo ' @@ -93,6 +94,7 @@ echo ' cat deploy/yamls/zfs.openebs.io_zfsrestores.yaml >> deploy/yamls/zfsrestore-crd.yaml rm deploy/yamls/zfs.openebs.io_zfsrestores.yaml +cp deploy/yamls/zfsrestore-crd.yaml deploy/helm/charts/crds/zfsrestore.yaml ## create the operator file using all the yamls