Skip to content

Merge pull request #69 from lukashornych/dev #53

Merge pull request #69 from lukashornych/dev

Merge pull request #69 from lukashornych/dev #53

Workflow file for this run

# Builds and releases a new public version of evitaLab a puts it into `Releases` section of GitHub
name: Release
on:
push:
branches:
- 'master'
permissions:
contents: read
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build-and-release:
name: Build and release
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
outputs:
release_id: ${{ steps.create_release.outputs.id }}
released_version: ${{ steps.release_version.outputs.version }}
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Resolve new release version
id: release_version
uses: codacy/[email protected]
with:
prefix: 'v'
minor-identifier: 'feat'
major-identifier: '(breaking)' # this should be placed somewhere in the commit message like "feat: (breaking) some message"
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18.16.1'
- name: Install dependencies
run: npm install -g yarn && yarn install --frozen-lockfile
- name: Build
env:
EVITALAB_BUILD_VERSION: ${{ steps.release_version.outputs.version }}
run: yarn build
- name: Include license in dist
run: cp LICENSE ./dist
- name: Create .zip of dist
uses: thedoctor0/[email protected]
with:
type: 'zip'
filename: 'dist.zip'
path: './dist'
- name: Create .tar.gz of dist
uses: thedoctor0/[email protected]
with:
type: 'tar'
filename: 'dist.tar.gz'
path: './dist'
- name: Create release
id: create_release
uses: release-drafter/release-drafter@v5
with:
version: ${{ steps.release_version.outputs.version }}
publish: true
- name: Upload dist.zip to release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist.zip
asset_name: Dist (zip)
asset_content_type: application/zip
- name: Upload dist.tar.gz to release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist.tar.gz
asset_name: Dist (tar.gz)
asset_content_type: application/gzip
build-and-release-docker:
name: Build and release Docker image
permissions:
packages: write
needs: build-and-release
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Log in to Docker hub
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
build-args: EVITALAB_BUILD_VERSION=${{ needs.build-and-release.outputs.released_version }}
context: .
file: ./Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build-and-release.outputs.released_version }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
# todo lho cannot find release id
# publish-release:
# name: Publish release
# needs: build-and-release-docker
# permissions:
# # write permission is required to create a github release
# contents: write
#
# runs-on: ubuntu-latest
#
# steps:
# - uses: StuYarrow/[email protected]
# with:
# id: ${{ needs.build-and-release.outputs.release_id }}