Merge pull request #39 from ekline-io/pp/EK-283-upgrade-ekline-cli-ve… #100
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: release | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- "v*.*.*" | |
pull_request: | |
types: | |
- labeled | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ekline-ci-cd | |
jobs: | |
release: | |
if: github.event.action != 'labeled' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# Bump version on merging Pull Requests with specific labels. | |
# (bump:major,bump:minor,bump:patch) | |
- id: bumpr | |
if: "!startsWith(github.ref, 'refs/tags/')" | |
uses: haya14busa/action-bumpr@v1 | |
# Get tag name. | |
- id: tag | |
uses: haya14busa/action-cond@v1 | |
with: | |
cond: "${{ startsWith(github.ref, 'refs/tags/') }}" | |
if_true: ${{ github.ref }} | |
if_false: ${{ steps.bumpr.outputs.next_version }} | |
# Create release | |
- if: "steps.tag.outputs.value != ''" | |
env: | |
TAG_NAME: ${{ steps.tag.outputs.value }} | |
BODY: ${{ steps.bumpr.outputs.message }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create "${TAG_NAME}" -t "Release ${TAG_NAME/refs\/tags\//}" --notes "${BODY}" | |
- if: "steps.tag.outputs.value != ''" | |
name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/ekline-io/${{ env.IMAGE_NAME }} | |
tags: | | |
type=semver,pattern=v{{version}},value=${{ steps.tag.outputs.value }} | |
type=semver,pattern=v{{major}}.{{minor}},value=${{ steps.tag.outputs.value }} | |
type=semver,pattern=v{{major}},value=${{ steps.tag.outputs.value }} | |
type=raw,value=latest | |
- if: "steps.tag.outputs.value != ''" | |
name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- if: "steps.tag.outputs.value != ''" | |
name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
# Update corresponding major and minor tag. | |
# e.g. Update v1 and v1.2 when releasing v1.2.3 | |
- uses: haya14busa/action-update-semver@v1 | |
if: "!steps.bumpr.outputs.skip" | |
with: | |
tag: ${{ steps.bumpr.outputs.next_version }} | |
- id: "tag_create" | |
if: "!steps.bumpr.outputs.skip" | |
uses: rickstaa/action-create-tag@v1 | |
with: | |
tag: "latest" | |
force_push_tag: true | |
message: "Latest release" | |
release-check: | |
if: github.event.action == 'labeled' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Post bumpr status comment | |
uses: haya14busa/action-bumpr@v1 |