Skip to content

[data-1613]

[data-1613] #520

Workflow file for this run

name: setup ci
on:
workflow_dispatch:
inputs:
GIT_REPO_FULL_NAME:
description: Select RepoName
required: false
type: choice
options:
- data2evidence/d2e
GIT_BRANCH_NAME:
default: develop
description: Enter BranchName / ReleaseTagName
required: true
type: string
tag:
description: Enter tag for release
required: true
type: string
release:
description: Enter name for github release
required: true
type: string
prerelease:
type: boolean
default: true
required: true
overwrite:
type: boolean
default: true
required: true
pull_request:
types: [opened, ready_for_review, reopened, synchronize]
push:
branches:
- develop
env:
GIT_BRANCH_NAME: ${{ github.event.inputs.GIT_BRANCH_NAME || github.head_ref || github.ref_name }} # workflow_dispatch || pull_request || push
GIT_REPO_FULL_NAME: ${{ github.event.inputs.GIT_REPO_FULL_NAME || github.event.pull_request.head.repo.full_name || github.event.repository.full_name }} # workflow_dispatch || pull_request || push
jobs:
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.GIT_BRANCH_NAME }}
repository: ${{ env.GIT_REPO_FULL_NAME }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "18.x"
registry-url: "https://npm.pkg.github.com"
scope: "@data2evidence"
- name: Update version
run: |
if [[ $GITHUB_EVENT_NAME == 'workflow_dispatch' ]]; then
RELEASE_VERSION=${{ github.event.inputs.tag }}
jq --arg v $RELEASE_VERSION '.version=$v' package.json > tmppkg; mv tmppkg package.json
else
jq --arg v "-$(date +%s)-$GITHUB_SHA" '.version+=$v' package.json > tmppkg; mv tmppkg package.json
fi
- name: npm build
run: npm install
# - name: Publish
# run: |
# if [[ $GIT_CI_BRANCH_NAME == 'develop' ]]; then
# npm publish
# else
# npm publish --dry-run
# fi
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#- uses: actions/delete-package-versions@v5
# if: github.ref_name == 'develop'
# with:
# package-name: "cli"
# package-type: "npm"
# min-versions-to-keep: 3
# delete-only-pre-release-versions: "true"
- name: Pack
run: |
NPM_FILENAME=$(npm pack)
echo "NPM_FILENAME=$NPM_FILENAME" >> $GITHUB_ENV
- name: Prepare
run: |
if [[ github.event_name == 'workflow_dispatch' ]]; then
echo "PRELEASE=${{ github.event.inputs.prerelease }}" | tee -a $GITHUB_ENV | tee -a $GITHUB_STEP_SUMMARY
echo "OVERWRITE=${{ github.event.inputs.overwrite }}" | tee -a $GITHUB_ENV | tee -a $GITHUB_STEP_SUMMARY
TAG=${{ github.event.inputs.tag }}
echo "TAG=$TAG" | tee -a $GITHUB_ENV | tee -a $GITHUB_STEP_SUMMARY
ASSET_NAME=data2evidence-cli-${TAG}
echo "ASSET_NAME=$ASSET_NAME" | tee -a $GITHUB_ENV | tee -a $GITHUB_STEP_SUMMARY
GITHUB_RELEASE=${{ github.event.inputs.release }}
echo "GITHUB_RELEASE=$GITHUB_RELEASE" | tee -a $GITHUB_ENV | tee -a $GITHUB_STEP_SUMMARY
else
echo "PRELEASE=true" | tee -a $GITHUB_ENV | tee -a $GITHUB_STEP_SUMMARY
echo "OVERWRITE=true" | tee -a $GITHUB_ENV | tee -a $GITHUB_STEP_SUMMARY
TAG=latest
echo "TAG=$TAG" | tee -a $GITHUB_ENV | tee -a $GITHUB_STEP_SUMMARY
ASSET_NAME=data2evidence-cli
echo "ASSET_NAME=$ASSET_NAME" | tee -a $GITHUB_ENV | tee -a $GITHUB_STEP_SUMMARY
echo "GITHUB_RELEASE=latest" | tee -a $GITHUB_ENV | tee -a $GITHUB_STEP_SUMMARY
fi
- name: Push
uses: svenstaro/upload-release-action@v2
if: github.ref_name == 'develop' || github.event_name == 'workflow_dispatch'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.NPM_FILENAME }}
tag: ${{ env.GITHUB_RELEASE }}
target_commit: ${{ github.ref_name }}
prerelease: ${{ env.PRELEASE }}
overwrite: ${{ env.OVERWRITE }}
asset_name: ${{ env.ASSET_NAME }}.tgz