|
| 1 | +name: Multi-Platform Build and Release |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: [published] |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - 'v*' |
| 8 | + branches: |
| 9 | + - 'master' |
| 10 | + paths-ignore: |
| 11 | + - 'docs/**' |
| 12 | + # - '.github/**' |
| 13 | + workflow_dispatch: |
| 14 | + inputs: |
| 15 | + release-ver: |
| 16 | + description: 'Stable Release Version' |
| 17 | + required: true |
| 18 | + default: 'v' |
| 19 | + stripped-release-ver: |
| 20 | + description: 'Stripped Stable Release Version' |
| 21 | + required: true |
| 22 | + default: '' |
| 23 | + release-channel: |
| 24 | + description: 'Release Channel' |
| 25 | + required: true |
| 26 | + default: 'edge' |
| 27 | + |
| 28 | +env: |
| 29 | + GIT_VERSION: ${{github.event.inputs.release-ver}} |
| 30 | + GIT_STRIPPED_VERSION: ${{github.event.inputs.stripped-release-ver}} |
| 31 | + RELEASE_CHANNEL: ${{github.event.inputs.release-channel}} |
| 32 | + GIT_TAG: ${{ github.event.release.tag_name }} |
| 33 | + |
| 34 | +jobs: |
| 35 | + print-inputs: |
| 36 | + runs-on: ubuntu-latest |
| 37 | + steps: |
| 38 | + |
| 39 | + - run: | |
| 40 | + echo "Dispatched GIT_VERSION: ${{github.event.inputs.release-ver}}" |
| 41 | + echo " Dispatched GIT_STRIPPED_VERSION: ${{github.event.inputs.stripped-release-ver}}" |
| 42 | + echo "Env RELEASE_CHANNEL: ${{env.RELEASE_CHANNEL}}" |
| 43 | + echo "Env GIT_VERSION: ${{env.GIT_VERSION}}" |
| 44 | + echo "Env GIT_STRIPPED_VERSION: ${{env.GIT_STRIPPED_VERSION}}" |
| 45 | + echo "Env GIT_TAG: ${{ github.event.release.tag_name }}" |
| 46 | + |
| 47 | + docker-build: |
| 48 | + runs-on: ubuntu-latest |
| 49 | + steps: |
| 50 | + - |
| 51 | + name: Checkout repo |
| 52 | + uses: actions/checkout@v3 |
| 53 | + - |
| 54 | + name: Identify Release Values |
| 55 | + if: "${{ github.event.inputs.release-ver}} != 'v' }}" |
| 56 | + run: | |
| 57 | + # GIT_REF=`git symbolic-ref HEAD` |
| 58 | + if [[ $GIT_TAG = refs/tags* ]] |
| 59 | + then |
| 60 | + echo RELEASE_CHANNEL=stable >> $GITHUB_ENV |
| 61 | + else |
| 62 | + echo RELEASE_CHANNEL=edge >> $GITHUB_ENV |
| 63 | + fi |
| 64 | + echo "Release channel determined to be $RELEASE_CHANNEL" |
| 65 | + LATEST_VERSION=$(git ls-remote --tags | tail -1 | cut -f2 | sed 's/refs\/tags\///g') >> $GITHUB_ENV |
| 66 | + GIT_VERSION=$(git ls-remote --tags | tail -1 | cut -f2 | sed 's/refs\/tags\///g') >> $GITHUB_ENV |
| 67 | + # GIT_VERSION=$(git describe --tags `git rev-list --tags --max-count=1` --always) |
| 68 | + GIT_STRIPPED_VERSION=$(git ls-remote --tags | tail -1 | cut -f2 | sed 's/refs\/tags\///g' | cut -c2-) |
| 69 | + echo "GIT_LATEST=$LATEST_VERSION" >> $GITHUB_ENV |
| 70 | + echo "GIT_VERSION=$GIT_VERSION" >> $GITHUB_ENV |
| 71 | + echo "GIT_STRIPPED_VERSION=$GIT_STRIPPED_VERSION" >> $GITHUB_ENV |
| 72 | + shell: bash |
| 73 | + |
| 74 | + - |
| 75 | + name: Set up QEMU |
| 76 | + uses: docker/setup-qemu-action@v1 |
| 77 | + - |
| 78 | + name: Set up Docker Buildx |
| 79 | + uses: docker/setup-buildx-action@v1 |
| 80 | + - |
| 81 | + name: Docker Meta |
| 82 | + id: meta |
| 83 | + uses: docker/metadata-action@v3 |
| 84 | + with: |
| 85 | + images: ${{ secrets.IMAGE_NAME }} |
| 86 | + flavor: | |
| 87 | + latest=false |
| 88 | + tags: | |
| 89 | + type=raw,value=${{env.RELEASE_CHANNEL}}-{{sha}} |
| 90 | + type=semver,pattern={{version}},value=${{env.GIT_STRIPPED_VERSION}} |
| 91 | + type=raw,pattern={{version}},value=${{env.RELEASE_CHANNEL}}-${{env.GIT_VERSION}} |
| 92 | + type=raw,value=${{env.RELEASE_CHANNEL}}-{{tag}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} |
| 93 | + type=raw,value=${{env.RELEASE_CHANNEL}}-latest |
| 94 | + type=semver,pattern={{version}},value=${{env.RELEASE_CHANNEL}}-${{env.GIT_VERSION}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} |
| 95 | + - |
| 96 | + name: Login to DockerHub |
| 97 | + uses: docker/login-action@v1 |
| 98 | + with: |
| 99 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 100 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 101 | + - |
| 102 | + name: Build and Push |
| 103 | + uses: docker/build-push-action@v2 |
| 104 | + with: |
| 105 | + context: "{{defaultContext}}" |
| 106 | + push: true |
| 107 | + build-args: | |
| 108 | + GIT_STRIPPED_VERSION=${{env.GIT_STRIPPED_VERSION}} |
| 109 | + GIT_VERSION=${{env.GIT_VERSION}} |
| 110 | + RELEASE_CHANNEL=${{env.RELEASE_CHANNEL}} |
| 111 | + tags: ${{ steps.meta.outputs.tags }} |
| 112 | + platforms: linux/amd64,linux/arm64 |
| 113 | + - |
| 114 | + name: Docker Hub Description |
| 115 | + uses: peter-evans/dockerhub-description@v3 |
| 116 | + with: |
| 117 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 118 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 119 | + repository: meshery/meshery-docker-extension |
| 120 | + readme-filepath: /install/docker-extension/README.md |
0 commit comments