[Integrate-1751] login page logo #11571
Workflow file for this run
This file contains hidden or 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: d2e/cli build and publish | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| GIT_REPO_FULL_NAME: | |
| description: Select RepoName | |
| required: false | |
| type: choice | |
| options: | |
| - OHDSI/Data2Evidence | |
| GIT_BRANCH_NAME: | |
| default: develop | |
| description: Enter BranchName / ReleaseTagName | |
| required: true | |
| type: string | |
| tag: | |
| description: Enter tag for release | |
| required: true | |
| type: string | |
| prerelease: | |
| type: boolean | |
| default: true | |
| required: true | |
| overwrite: | |
| type: boolean | |
| default: true | |
| required: true | |
| environment: | |
| description: Select deployment environment | |
| required: false | |
| type: choice | |
| default: npm | |
| options: | |
| - npm | |
| - github | |
| pull_request: | |
| types: [opened, ready_for_review, reopened, synchronize] | |
| merge_group: | |
| 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 | |
| environment: ${{github.event_name == 'workflow_dispatch' && github.event.inputs.environment || 'github'}} | |
| 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 | |
| if: github.event_name != 'workflow_dispatch' || github.event.inputs.environment == 'github' | |
| with: | |
| node-version: "18.x" | |
| registry-url: "https://npm.pkg.github.com" | |
| scope: "@ohdsi" | |
| - name: Use Node.js (prod) | |
| uses: actions/setup-node@v2 | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'npm' | |
| with: | |
| node-version: '18' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Update version | |
| run: | | |
| if [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then | |
| RELEASE_VERSION=${{ github.event.inputs.tag }} | |
| if [[ "${{ github.event.inputs.environment }}" == 'npm' ]]; then | |
| # Unscoped name for npmjs.org | |
| jq --arg v $RELEASE_VERSION '.version=$v | .name="d2e" | del(.optionalDependencies)' package.json > tmppkg; mv tmppkg package.json | |
| else | |
| # Keep scoped name for GitHub Packages | |
| jq --arg v $RELEASE_VERSION '.version=$v | del(.optionalDependencies)' package.json > tmppkg; mv tmppkg package.json | |
| fi | |
| else | |
| jq --arg v "-$(date +%s)-$GITHUB_SHA" '.version+=$v | del(.optionalDependencies)' package.json > tmppkg; mv tmppkg package.json | |
| fi | |
| - name: npm build | |
| run: npm install | |
| - name: Publish | |
| run: | | |
| if [[ (${{ env.GIT_BRANCH_NAME }} == 'develop' && ${{ github.event_name }} != 'workflow_dispatch') || (${{ github.event_name }} == 'workflow_dispatch' && "${{ github.event.inputs.environment }}" == 'github') ]]; then | |
| npm publish | |
| else | |
| npm publish --dry-run | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish production | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'npm' | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPMJS_TOKEN }} | |
| - uses: actions/delete-package-versions@v5 | |
| if: github.ref_name == 'develop' | |
| with: | |
| package-name: "d2e" | |
| package-type: "npm" | |
| min-versions-to-keep: 3 | |
| delete-only-pre-release-versions: "true" | |
| - name: Pack | |
| run: | | |
| NPM_FILENAME=$(npm pack | tail -n 1) | |
| 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=v${{ github.event.inputs.tag }} | |
| 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 |