Skip to content

feat: new version

feat: new version #15

name: Build, Push, and Release
on:
push:
branches:
- ft/versioning
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./Website/ui
file: ./Website/ui/Dockerfile
platforms: linux/amd64
push: true
tags: enaccess/mpm-frontend:latest
release:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install dependencies
working-directory: ./
run: npm install
- name: Fetch tags
run: git fetch --tags
- name: Determine next version
id: determine_version
run: |
# Check if any tags exist
if git tag -l | grep -q '^v'; then
# Get the latest tag
LATEST_TAG=$(git describe --tags --abbrev=0)
else
# If no tags, set the initial tag
LATEST_TAG='v0.0.0'
fi
# Run semantic-release to get the next version
NEXT_VERSION=$(npx semantic-release --dry-run | grep 'Next version' | awk '{print $NF}')
echo "NEXT_VERSION=${NEXT_VERSION}" >> $GITHUB_ENV
- name: Run semantic-release
working-directory: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
- name: Check if release was successful
if: success() && env.NEXT_VERSION != ''
run: echo "New version created ${{ env.NEXT_VERSION }}"