Skip to content

feat: add semantic release #2

feat: add semantic release

feat: add semantic release #2

Workflow file for this run

name: Docker image
on: [push, pull_request]
jobs:
build:
# if: github.repository == 'casvisor/dbgate' && github.event_name == 'push'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: -1
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Fetch Previous version
id: get-previous-tag
uses: actions-ecosystem/action-get-latest-tag@v1.6.0
- name: Release
run: yarn global add semantic-release@17.4.4 && semantic-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch Current version
id: get-current-tag
uses: actions-ecosystem/action-get-latest-tag@v1.6.0
- name: Decide Should_Push Or Not
id: should_push
run: |
old_version=${{steps.get-previous-tag.outputs.tag}}
new_version=${{steps.get-current-tag.outputs.tag }}
old_array=(${old_version//\./ })
new_array=(${new_version//\./ })
if [ ${old_array[0]} != ${new_array[0]} ]
then
echo ::set-output name=push::'true'
elif [ ${old_array[1]} != ${new_array[1]} ]
then
echo ::set-output name=push::'true'
else
echo ::set-output name=push::'false'
fi
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 16.x
- name: yarn install
run: |
# yarn --version
# yarn config set network-timeout 300000
yarn install
- name: setCurrentVersion
run: |
yarn setCurrentVersion
- name: Prepare docker image
run: |
yarn run prepare:docker
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
if: steps.should_push.outputs.push == 'true'
uses: docker/build-push-action@v3
with:
push: true
context: ./docker
tags: casbin/dbgate:${{steps.get-current-tag.outputs.tag }},casbin/dbgate:latest
platforms: linux/amd64,linux/arm64,linux/arm/v7
- name: Build and push alpine
if: steps.should_push.outputs.push == 'true'
uses: docker/build-push-action@v3
with:
push: true
context: ./docker
file: ./docker/Dockerfile-alpine
tags: casbin/dbgate:${{steps.get-current-tag.outputs.tag }}-alpine
platforms: linux/amd64,linux/arm64,linux/arm/v7