Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIO-7507: Publish dev tag to npm #1060

Merged
merged 29 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2efb983
init test
ryanformio Mar 20, 2024
fab3493
Run publish
ryanformio Mar 20, 2024
59c1672
View unclean directory
ryanformio Mar 20, 2024
8098c84
Adding --no-git-tag-version to npm version
ryanformio Mar 20, 2024
eadad3a
Forgot to uncomment
ryanformio Mar 20, 2024
2e45ec8
Not sure how these got backwards
ryanformio Mar 20, 2024
edbc24e
Seems the reason is due to the existence of publish in package.json
ryanformio Mar 20, 2024
4598086
Add run
ryanformio Mar 20, 2024
e2d3f52
restore build cache and run publish
ryanformio Mar 20, 2024
b2f21b7
Change directory where git user and npmrc occur
ryanformio Mar 20, 2024
72ce0cd
test
ryanformio Mar 22, 2024
0378d72
Publish Dry run
ryanformio Mar 22, 2024
7fccf00
View git status for unclean directory
ryanformio Mar 22, 2024
8c9f7fd
Navigate to the dir and publish
ryanformio Mar 22, 2024
3c232c0
Moves the npm token around
ryanformio Mar 22, 2024
3b0b971
Getting unclean dir
ryanformio Mar 22, 2024
8de3677
try adding .npmrc to ignore
ryanformio Mar 22, 2024
f7c9795
Adds --no-git-tag-version so will by pass the modifications to .npmrc
ryanformio Mar 22, 2024
48ab78d
Try from cache again
ryanformio Mar 22, 2024
b272e25
seems like it will fail without no-git-tag but still push
ryanformio Mar 22, 2024
f6448ba
Its not publishing from the correct directory it seems
ryanformio Mar 22, 2024
e61e78c
directory test
ryanformio Mar 22, 2024
59f26ea
Having issues getting it to deploy to correct directory
ryanformio Mar 22, 2024
f605790
switch dirs before creating tag
ryanformio Mar 22, 2024
daa6205
Adds working directory to steps
ryanformio Mar 22, 2024
57ea833
Last minute clean-up
ryanformio Mar 22, 2024
dd7e31e
Merge branch 'master' into FIO-7507-publish-dev-tag-to-npm
ryanformio Apr 3, 2024
e62b35a
Updates with 7848 and uses yarn publish
ryanformio Apr 3, 2024
8982fec
Updates for FIO-8237, and addresses PR comments in formioreport.compo…
ryanformio May 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
231 changes: 231 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
name: Build, Publish

on:
pull_request:
types: [opened, synchronize, reopened]

env:
NODE_VERSION: 20.x

jobs:
#####################################################################
## Setup
#####################################################################
setup:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- run: echo "Triggered by ${{ github.event_name }} event."

- name: Check out repository code ${{ github.repository }} on ${{ github.ref }}
uses: actions/checkout@v3

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-

- name: Installing dependencies
if: steps.cache.outputs.cache-hit != 'true'
uses: borales/actions-yarn@v4
with:
cmd: install --frozen-lockfile

# - name: Lint
# uses: borales/actions-yarn@v4
# with:
# cmd: lint

#####################################################################
## Build
#####################################################################
build:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Check out repository code ${{ github.repository }} on ${{ github.ref }}
uses: actions/checkout@v3

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Restore node modules from cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-

- name: Build
uses: borales/actions-yarn@v4
with:
cmd: build:prod

- name: Show build directory contents
run: |
ls -R ./dist/angular-formio

- name: Cache dist directory
uses: actions/cache@v3
with:
path: dist
key: ${{ runner.os }}-dist-${{ hashFiles('dist.tgz') }}
restore-keys: |
${{ runner.os }}-dist-

#####################################################################
## Test (Trys to launch a chrome browser, will need additional work)
#####################################################################
# test-current:
# needs: setup
# runs-on: ubuntu-latest
# steps:
# - name: Check out repository code ${{ github.repository }} on ${{ github.ref }}
# uses: actions/checkout@v3

# - name: Restore node modules from cache
# uses: actions/cache@v3
# with:
# path: node_modules
# key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-node-

# - name: Test
# uses: borales/actions-yarn@v4
# with:
# cmd: test

# test-target:
# needs: setup
# runs-on: ubuntu-latest
# steps:
# - name: Check out repository code ${{ github.repository }} on ${{ github.ref }}
# uses: actions/checkout@v3
# with:
# fetch-depth: 0

# - name: Merge target branch into current branch
# run: |
# git config --global user.email "[email protected]"
# git config --global user.name "pkgbot"
# git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }}
# git merge ${{ github.event.pull_request.base.ref }} --no-commit --no-ff
# if ! git merge --no-commit --no-ff ${{ github.event.pull_request.base.ref }}; then
# echo "Merge conflicts detected."
# git merge --abort
# exit 1
# else
# echo "Merge successful."
# fi

# - name: Set up Node.js ${{ env.NODE_VERSION }}
# uses: actions/setup-node@v3
# with:
# node-version: ${{ env.NODE_VERSION }}
# cache: 'npm'

# - name: Restore node modules from cache
# uses: actions/cache@v3
# with:
# path: node_modules
# key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-node-

# - name: Test
# uses: borales/actions-yarn@v4
# with:
# cmd: test

#####################################################################
## Publish
#####################################################################
publish:
needs: [setup, build]
if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'synchronize') }}
runs-on: ubuntu-latest
steps:
- name: Check out repository code ${{ github.repository }} on ${{ github.ref }}
uses: actions/checkout@v3

- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
registry-url: 'https://registry.npmjs.org/'

# Restore Build cache
- name: Restore dist cache
uses: actions/cache@v3
with:
path: dist
key: ${{ runner.os }}-dist-${{ hashFiles('dist.tgz') }}
restore-keys: |
${{ runner.os }}-dist-

# - name: Switch to dist directory
# run: |
# cd ./dist/angular-formio
# ls -R .

- name: Prepare version for publish
id: prep
working-directory: ./dist/angular-formio
run: |
# Extract the pull request number and the short SHA of the commit
PR_NUMBER=$(echo ${{ github.event.number }})
COMMIT_SHORT_SHA=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c1-7)

# Extract the current version from package.json
CURRENT_VERSION=$(node -p "require('./package.json').version")

# Get base SemVer to us for new dev version
BASE_VERSION=$(echo "$CURRENT_VERSION" | cut -d'-' -f1)

# Construct the new version string
NEW_VERSION="${BASE_VERSION}-dev.${PR_NUMBER}.${COMMIT_SHORT_SHA}"

# Output the new version for use in subsequent GitHub Actions steps
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV

- name: Echo version to Publish
run: |
echo "Version to publish: $NEW_VERSION"

- name: Configure Git user
working-directory: ./dist/angular-formio
run: |
git config --global user.email "[email protected]"
git config --global user.name "pkgbot"

- name: Add npm token to .npmrc
working-directory: ./dist/angular-formio
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc

- name: Publish to npm
working-directory: ./dist/angular-formio
run: |
npm version $NEW_VERSION
yarn publish --tag=dev

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ testem.log
# System Files
.DS_Store
Thumbs.db

.npmrc
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ Desktop.ini
# Library files
src/*
build/*

.npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export class FormioReportComponent extends FormioComponent implements OnInit, On
@Output() fetchDataError = new EventEmitter<any>();
@ViewChild('report', { static: true }) declare formioElement?: ElementRef<any>;

public isLoading: boolean;

setFormFromSrc() {
this.service.loadSubmission({ params: { live: 1 } }).subscribe(
(report: FormioReport) => {
Expand Down
Loading