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-6632: Automate @formio/js updates to formiojs.test-form.io #5666

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 28 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: Release
on:
push:
tags:
- '*' # This will make sure tag creations also trigger the workflow.

- '*'
env:
NODE_VERSION: 20.x
AWS_DEFAULT_REGION: us-west-2
Expand All @@ -31,6 +30,11 @@ jobs:
- name: Install Jekyll
run: gem install jekyll

- name: Install awscli
run: |
sudo apt-get update
sudo apt install -y awscli

- name: Restore node modules from cache
uses: actions/cache@v3
with:
Expand All @@ -39,12 +43,29 @@ jobs:
restore-keys: |
${{ runner.os }}-node-

- name: Install awscli
run: |
sudo apt-get update
sudo apt install -y awscli
- name: Installing dependencies
if: steps.cache.outputs.cache-hit != 'true'
uses: borales/actions-yarn@v4
with:
cmd: install --frozen-lockfile

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

- name: Release
uses: borales/actions-yarn@v4
with:
cmd: release
cmd: release

- name: Invalidate (formiojs.test-form.io) Cloudfront cache
uses: borales/actions-yarn@v4
with:
cmd: invalidate

- name: Echo link to Test Page
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "The extracted version is $VERSION"
echo "https://formiojs.test-form.io/$VERSION"
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@formio/js",
"version": "5.0.0-rc.59",
"version": "5.0.0-rc.60",
"description": "JavaScript powered Forms with JSON Form Builder",
"main": "lib/cjs/index.js",
"exports": {
Expand Down Expand Up @@ -38,7 +38,7 @@
"lint"
],
"scripts": {
"build": "yarn doc && yarn lib && yarn dist",
"build": "chmod +x update_semver.sh &&./update_semver.sh && yarn doc && yarn lib && yarn dist",
"doc": "typedoc",
"dist": "gulp clean:dist && webpack --config webpack.config.js && webpack --config webpack.prod.js && gulp build",
"lib": "gulp clean:lib && tsc --project tsconfig.cjs.json && tsc --project tsconfig.mjs.json && yarn lib:package",
Expand All @@ -50,7 +50,7 @@
"build-app:jekyll": "jekyll build --config _config.yml,_config.app.yml",
"gh-pages": "rm -rf _site && npm run build && jekyll build --config _config.yml && cd _site && git init && git remote add origin [email protected]:formio/formio.js.git && git checkout -b gh-pages && git add . && git commit -m \"Deploy to GitHub Pages\" && git push origin gh-pages --force && cd ..",
"deploy-s3": "$(node -e 'process.stdout.write(`aws s3 cp _site s3://formiojs.test-form.io/` + require(`./package.json`).version + `/ --recursive`)')",
"invalidate": "VERSION=$(yarn version);aws cloudfront create-invalidation --distribution-id E1MXNA5A4ZKRMZ --paths \"/$VERSION/*\"",
"invalidate": "VERSION=$(yarn version --json | jq -r '.data' | sed -n 's/.*: \\(.*\\)/\\1/p'); aws cloudfront create-invalidation --distribution-id E1MXNA5A4ZKRMZ --paths \"/$VERSION/*\"",
"release": "yarn build-app && yarn deploy-s3",
"tag": "VERSION=$(yarn version);git add -A; git commit -m \"Build $Version\";git push origin master;git tag v$VERSION;git push origin --tags;",
"dopublish": "npm run build && npm run tag && npm publish",
Expand Down
48 changes: 48 additions & 0 deletions update_semver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

# Function to extract version from package.json
get_version_from_package_json() {
version=$(jq -r '.version' package.json)
echo $version
}

# Function to get the latest git tag
get_latest_git_tag() {
tag=$(git describe --tags --abbrev=0)
if [ $? -ne 0 ]; then
echo "No git tags found."
exit 1
fi
echo $tag
}

# Function to strip the leading 'v' from the tag if it exists
strip_leading_v() {
local tag=$1
echo "${tag#v}"
}

# Main script
main() {
if ! [ -f "package.json" ]; then
echo "package.json not found."
exit 1
fi

version=$(get_version_from_package_json)
echo "Current package.json version: $version"

tag=$(get_latest_git_tag)
echo "Latest git tag: $tag"

stripped_tag=$(strip_leading_v "$tag")
echo "Stripped tag: $stripped_tag"

# Update package.json version with the stripped tag
jq --arg tag "$stripped_tag" '.version = $tag' package.json > temp.json && mv temp.json package.json

echo "Updated package.json version to: $stripped_tag"
}

# Execute the main script
main