|
| 1 | +# mvp: https://github.com/mariadb-corporation/skysql-api-go/blob/main/.github/workflows/publish.yml |
| 2 | +name: Publish |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - 'master' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +env: |
| 10 | + REGISTRY: ghcr.io |
| 11 | + IMAGE_NAME: ${{ github.repository }} |
| 12 | + |
| 13 | +jobs: |
| 14 | + release: |
| 15 | + name: Publish new release |
| 16 | + if: github.ref == 'refs/heads/master' |
| 17 | + timeout-minutes: 5 |
| 18 | + runs-on: ubuntu-latest |
| 19 | + outputs: |
| 20 | + version: ${{ steps.version.outputs.version }} |
| 21 | + steps: |
| 22 | + - name: Check Out Repo |
| 23 | + uses: actions/checkout@v2 |
| 24 | + with: # https://stackoverflow.com/a/65081720 |
| 25 | + ref: ${{ github.event.workflow_run.head_branch }} |
| 26 | + fetch-depth: "0" |
| 27 | + - name: Install Auto |
| 28 | + run : npm i -g auto @auto-it/upload-assets @auto-it/git-tag @auto-it/pr-body-labels @auto-it/exec |
| 29 | + - name: Configure git |
| 30 | + run: | |
| 31 | + git config --global user.email "[email protected]" |
| 32 | + git config --global user.name "seraf-ci-bot" |
| 33 | + - name: Publish new version |
| 34 | + run: GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" auto shipit |
| 35 | + - id: version |
| 36 | + name: Output new version |
| 37 | + run: echo "::set-output name=version::$(git describe --tags)" |
| 38 | + |
| 39 | + docker-push: |
| 40 | + needs: release |
| 41 | + runs-on: ubuntu-latest |
| 42 | + |
| 43 | + permissions: |
| 44 | + contents: read |
| 45 | + packages: write |
| 46 | + |
| 47 | + steps: |
| 48 | + - name: Checkout |
| 49 | + uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - name: Log in to the Container registry |
| 52 | + uses: docker/login-action@v2 |
| 53 | + with: |
| 54 | + registry: ${{ env.REGISTRY }} |
| 55 | + username: ${{ github.actor }} |
| 56 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + |
| 58 | + - name: Extract metadata (tags, labels) for Docker |
| 59 | + id: meta |
| 60 | + uses: docker/metadata-action@v4 |
| 61 | + with: |
| 62 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 63 | + |
| 64 | + - name: Docker Build and Push Backend |
| 65 | + uses: docker/build-push-action@v4 |
| 66 | + with: |
| 67 | + push: true |
| 68 | + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.version }} |
| 69 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments