name: release on: push: branches: - master jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2.1.1 with: node-version: 14 - uses: actions/cache@v2 with: path: ~/.npm key: client-${{ hashFiles('**/package-lock.json') }} - run: npm ci env: SKIP_BUILD: true - run: npm run lint -- --no-fix release: needs: test runs-on: ubuntu-latest outputs: published: ${{ steps.release.outputs.published }} release-version: ${{ steps.release.outputs.release-version }} release-version-major: ${{ steps.release.outputs.release-version-major }} release-version-minor: ${{ steps.release.outputs.release-version-minor }} steps: - uses: actions/checkout@v2 - run: npm ci env: SKIP_BUILD: true - id: release name: semantic-release uses: ahmadnassri/action-semantic-release@v1 env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} npm_config_unsafe_perm: true alias: needs: release if: needs.release.outputs.published == 'true' runs-on: ubuntu-latest strategy: matrix: alias: - version: v${{ needs.release.outputs.release-version-major }} - version: v${{ needs.release.outputs.release-version-major }}.${{ needs.release.outputs.release-version-minor }} steps: - uses: actions/github-script@v3 with: script: | const tag = 'tags/${{ matrix.alias.version }}' const repo = { owner: context.repo.owner, repo: context.repo.repo } await github.git.deleteRef({ ...repo, ref: tag }).catch(() => {}) await github.git.createRef({ ...repo, ref: `refs/${tag}` , sha: process.env.GITHUB_SHA }) buildx: needs: release if: needs.release.outputs.published == 'true' runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Prepare id: prepare run: | DOCKER_IMAGE=${{ github.event.repository.full_name }} DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x TAGS="--tag ${DOCKER_IMAGE}:latest --tag ${DOCKER_IMAGE}:${{ needs.release.outputs.release-version }} --tag ${DOCKER_IMAGE}:v${{ needs.release.outputs.release-version-major }}" echo ::set-output name=docker_image::${DOCKER_IMAGE} echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ --build-arg REVISION=${GITHUB_SHA:0:7} \ --build-arg VERSION=${{ needs.release.outputs.release-version }} \ --cache-from "type=local,src=/tmp/.buildx-cache" \ --cache-to "type=local,dest=/tmp/.buildx-cache" \ ${TAGS} --file ./Dockerfile ./ - name: Set up Docker Buildx uses: crazy-max/ghaction-docker-buildx@v3 - name: Cache Docker layers uses: actions/cache@v2 env: cache-name: cache-buildx id: cache with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }}-${{ env.cache-name }} restore-keys: | ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }} ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }} ${{ runner.os }}-buildx- - name: Docker Buildx (build) run: | docker buildx build \ --output "type=image,push=false" \ ${{ steps.prepare.outputs.buildx_args }} - name: Docker Login env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} run: | echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin - name: Docker Buildx (push) run: | docker buildx build \ --output "type=image,push=true" \ ${{ steps.prepare.outputs.buildx_args }} - name: Docker Check Manifest run: | docker run --rm mplatform/mquery ${{ steps.prepare.outputs.docker_image }}:${{ needs.release.outputs.release-version }} - name: Clear if: always() run: | rm -f ${HOME}/.docker/config.json buildx-web: needs: release if: needs.release.outputs.published == 'true' runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Prepare id: prepare run: | DOCKER_IMAGE=ttshivers/syncloungeweb DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x TAGS="--tag ${DOCKER_IMAGE}:latest --tag ${DOCKER_IMAGE}:${{ needs.release.outputs.release-version }} --tag ${DOCKER_IMAGE}:v${{ needs.release.outputs.release-version-major }}" echo ::set-output name=docker_image::${DOCKER_IMAGE} echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ --build-arg REVISION=${GITHUB_SHA:0:7} \ --build-arg VERSION=${{ needs.release.outputs.release-version }} \ --cache-from "type=local,src=/tmp/.buildx-cache" \ --cache-to "type=local,dest=/tmp/.buildx-cache" \ ${TAGS} --file ./Dockerfile.web ./ - name: Set up Docker Buildx uses: crazy-max/ghaction-docker-buildx@v3 - name: Cache Docker layers uses: actions/cache@v2 env: cache-name: cache-buildx-web id: cache with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }}-${{ env.cache-name }} restore-keys: | ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }} ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }} ${{ runner.os }}-buildx- - name: Docker Buildx (build) run: | docker buildx build \ --output "type=image,push=false" \ ${{ steps.prepare.outputs.buildx_args }} - name: Docker Login env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} run: | echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin - name: Docker Buildx (push) run: | docker buildx build \ --output "type=image,push=true" \ ${{ steps.prepare.outputs.buildx_args }} - name: Docker Check Manifest run: | docker run --rm mplatform/mquery ${{ steps.prepare.outputs.docker_image }}:${{ needs.release.outputs.release-version }} - name: Clear if: always() run: | rm -f ${HOME}/.docker/config.json