Skip to content

Commit

Permalink
[RND-649] Add lerna version update process into GitHub Action (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
andonyns authored Nov 14, 2023
1 parent 9920048 commit b936443
Show file tree
Hide file tree
Showing 25 changed files with 238 additions and 6,430 deletions.
23 changes: 11 additions & 12 deletions .github/workflows/on-merge-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,30 @@ env:
GITHUB_TOKEN: ${{ secrets.PAT_ATTACH_TO_RELEASE }}

jobs:

create-pre-releases:
name: Create Pre-Releases
runs-on: ubuntu-latest
defaults:
run:
shell: pwsh
working-directory: eng/version
working-directory: Meadowlark-js
steps:
- name: Checkout the Repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
# Need full Git history for calculating the version number
fetch-depth: 0w

- name: Set Version
id: set-version
run: |
version=v$(cat lerna.json | jq -r .version)
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Create Meadowlark Pre-Release
shell: pwsh
run: |
npm install
$version = $(node ./bump.js)
if ($LASTEXITCODE -ne 0) {
throw 'Unable to retrieve version number'
}
$version="${{steps.set-version.outputs.version}}"
"Creating pre-release $version" | Out-Host
$body = @{
tag_name = "$version"
tag_name = $version
target_commitish = "main"
name = $version
body = ""
Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/on-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
# Need full Git history for calculating the version number
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1
Expand All @@ -42,15 +39,8 @@ jobs:
cache-dependency-path: "**/package-lock.json"

- name: Install dependencies
if: ${{ steps.modules-cache.outputs.cache-hit != 'true' }}
run: npm ci

- name: Update version to match tag
working-directory: eng/version
run: |
npm ci --omit dev
node ./set.js ${{ env.REF }}
- name: Transpile to JS
run: npm run build --workspaces

Expand All @@ -74,9 +64,6 @@ jobs:
- name: Publish
run: npm publish --workspaces --tag dev
# NOTE: there are uncommitted version number changes in package.json. No
# problem! Our strategy is to rely on the tag history for version numbers,
# not on package.json.

- name: Generate hash codes for npm tarballs
id: hash-code
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/on-pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
- ".github/**"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: abcdefgh1!
Expand Down Expand Up @@ -112,6 +116,49 @@ jobs:
- name: Linter
run: npm run test:lint

upgrade:
# Upgrade packages on PR only to avoid a double update when pushed to main
name: Upgrade packages
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
defaults:
run:
working-directory: Meadowlark-js
permissions:
contents: write
steps:
- name: Checkout the Repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: 0w

- name: Get changes
id: changes
run: |
suggested=v$(cat lerna.json | jq -r .version)
current=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "changes=$([[ "$suggested" != "$current" ]] && echo true)" >>$GITHUB_OUTPUT
- name: Update versions
if: ${{ ! steps.changes.outputs.changes }}
run: npx [email protected] version prerelease --exact --no-git-tag-version --yes

- name: Set Version
if: ${{ ! steps.changes.outputs.changes }}
id: set-version
run: |
version=v$(cat lerna.json | jq -r .version)
echo "version=$version" >> "$GITHUB_OUTPUT"
- uses: planetscale/ghcommit-action@4131649dbf2fdf1eb34421702972a5af7b0a8731 #v0.1.18
if: ${{ ! steps.changes.outputs.changes }}
with:
commit_message: "${{steps.set-version.outputs.version}}"
repo: ${{ github.repository }}
branch: ${{ github.head_ref || github.ref_name }}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

build:
name: Build
needs: lint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@edfi/meadowlark-elasticsearch-backend",
"main": "dist/index.js",
"version": "0.3.6-pre-36",
"version": "0.4.0-pre.0",
"description": "Meadowlark backend plugin for elasticsearch",
"license": "Apache-2.0",
"publishConfig": {
Expand All @@ -19,8 +19,8 @@
"build:copy-non-ts": "copyfiles -u 1 -e \"**/*.ts\" \"src/**/*\" dist --verbose"
},
"dependencies": {
"@edfi/meadowlark-core": "^v0.3.6-pre-36",
"@edfi/meadowlark-utilities": "^v0.3.6-pre-36",
"@edfi/meadowlark-core": "0.4.0-pre.0",
"@edfi/meadowlark-utilities": "0.4.0-pre.0",
"@elastic/elasticsearch": "^8.10.0",
"@elastic/transport": "^8.3.4"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@edfi/meadowlark-mongodb-backend",
"main": "dist/index.js",
"version": "0.3.6-pre-36",
"version": "0.4.0-pre.0",
"description": "Meadowlark backend plugin for MongoDB",
"license": "Apache-2.0",
"publishConfig": {
Expand All @@ -19,9 +19,9 @@
"build:copy-non-ts": "copyfiles -u 1 -e \"**/*.ts\" \"src/**/*\" dist --verbose"
},
"dependencies": {
"@edfi/meadowlark-authz-server": "^v0.3.6-pre-36",
"@edfi/meadowlark-core": "^v0.3.6-pre-36",
"@edfi/meadowlark-utilities": "^v0.3.6-pre-36",
"@edfi/meadowlark-authz-server": "0.4.0-pre.0",
"@edfi/meadowlark-core": "0.4.0-pre.0",
"@edfi/meadowlark-utilities": "0.4.0-pre.0",
"async-retry": "^1.3.3",
"mongodb": "^5.9.0",
"ramda": "0.29.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@edfi/meadowlark-opensearch-backend",
"main": "dist/index.js",
"version": "0.3.6-pre-36",
"version": "0.4.0-pre.0",
"description": "Meadowlark backend plugin for OpenSearch",
"license": "Apache-2.0",
"publishConfig": {
Expand All @@ -19,8 +19,8 @@
"build:copy-non-ts": "copyfiles -u 1 -e \"**/*.ts\" \"src/**/*\" dist --verbose"
},
"dependencies": {
"@edfi/meadowlark-core": "^v0.3.6-pre-36",
"@edfi/meadowlark-utilities": "^v0.3.6-pre-36",
"@edfi/meadowlark-core": "0.4.0-pre.0",
"@edfi/meadowlark-utilities": "0.4.0-pre.0",
"@opensearch-project/opensearch": "^2.4.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@edfi/meadowlark-postgresql-backend",
"main": "dist/index.js",
"version": "0.3.6-pre-36",
"version": "0.4.0-pre.0",
"description": "Meadowlark backend plugin for PostgreSQL",
"license": "Apache-2.0",
"publishConfig": {
Expand All @@ -19,13 +19,12 @@
"build:copy-non-ts": "copyfiles -u 1 -e \"**/*.ts\" \"src/**/*\" dist --verbose"
},
"dependencies": {
"@edfi/meadowlark-authz-server": "^v0.3.6-pre-36",
"@edfi/meadowlark-core": "^v0.3.6-pre-36",
"@edfi/meadowlark-utilities": "^v0.3.6-pre-36",
"@edfi/meadowlark-authz-server": "0.4.0-pre.0",
"@edfi/meadowlark-core": "0.4.0-pre.0",
"@edfi/meadowlark-utilities": "0.4.0-pre.0",
"pg": "^8.11.3",
"pg-format": "^1.0.4",
"ramda": "0.29.1"

},
"devDependencies": {
"@testcontainers/postgresql": "^10.2.1",
Expand Down
9 changes: 2 additions & 7 deletions Meadowlark-js/lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
"packages": [
"packages/*"
],
"version": "v0.3.0-pre-35",
"version": "0.4.0-pre.0",
"npmClient": "npm",
"useWorkspaces": true,
"command": {
"version": {
"allowBranch": "main"
}
}
"useWorkspaces": true
}
Loading

0 comments on commit b936443

Please sign in to comment.