Cleanup and separate node & docker jobs #1
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: Build and Release | ||
on: | ||
workflow_call: | ||
inputs: | ||
commit_sha: | ||
required: true | ||
type: string | ||
jobs: | ||
release: | ||
name: 'Semantic Release NodeJS' | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [ '18.x' ] | ||
outputs: | ||
NEW_TAG: ${{ steps.bump-tag.outputs.new_tag }} | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.commit_sha }} | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'yarn' | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
- name: Run Build | ||
run: yarn build | ||
- name: Bump version and push tag | ||
id: bump-tag | ||
uses: anothrNick/github-tag-action@1.64.0 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
WITH_V: true | ||
RELEASE_BRANCHES: 'master,main' | ||
PRERELEASE: true | ||
- name: Sync package.json version | ||
run: | | ||
TAG="${{ steps.bump-tag.outputs.new_tag }}" | ||
NEW_VERSION="${TAG#v}" | ||
npm version $NEW_VERSION --no-git-tag-version -m "Update package.json version [skip-ci]" | ||
git push origin HEAD:${{ github.ref }} | ||
release-docker: | ||
name: 'Build and Release Docker Image' | ||
runs-on: ubuntu-latest | ||
needs: release | ||
env: | ||
IMAGE_NAME: ${{ github.repository_owner }}/${{ github.repository_name }}:${{ needs.release.outputs.NEW_TAG }} | ||
steps: | ||
- name: Login to GitHub Packages | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: | | ||
ghcr.io/${{ env.IMAGE_NAME }} |