Skip to content

Commit

Permalink
feat(cicd): simplify using release-please
Browse files Browse the repository at this point in the history
  • Loading branch information
azlam committed Jun 29, 2024
1 parent b631f2d commit 6312fdf
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 50 deletions.
3 changes: 0 additions & 3 deletions .github/FUNDING.yml

This file was deleted.

6 changes: 1 addition & 5 deletions .github/workflows/buildPackages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ jobs:
with:
fetch-depth: 0

- uses: pnpm/action-setup@v2
with:
version: 8

- uses: actions/setup-node@v3
with:
node-version: '18'
node-version: 20
registry-url: https://registry.npmjs.org/

- name: 'Set Git Config'
Expand Down
21 changes: 0 additions & 21 deletions .github/workflows/cherry-picker.yml

This file was deleted.

60 changes: 43 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,41 @@ on:

# Merge to Develop, create builds
jobs:
build:
name: 'build packages'
uses: ./.github/workflows/buildPackages.yml
with:
version: ${{ github.ref }}
publish: true
environment: build
secrets:
npm-token: ${{ secrets.NPM_TOKEN }}
release-please:
outputs:
continue: ${{ steps.release.outputs.releases_created }}
released_version: ${{ steps.release.outputs.major || steps.release.outputs.minor || steps.release.outputs.patch }}
permissions:
contents: write # to create release commit (google-github-actions/release-please-action)
packages: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
token: ${{ secrets.NPM_TOKEN }}
registry-url: 'https://registry.npmjs.org'

- uses: google-github-actions/release-please-action@v4
id: release
with:
token: ${{ secrets.NPM_TOKEN }}
config-file: release-please-config.json
- run: |
npm i
npm publish
name: Publish packages
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: ${{ steps.release.outputs.releases_created == 'true'}}
# On successfull creation of packages,(or even if lerna skips), create docker image
build-docker:
name: 'build docker image'
uses: ./.github/workflows/sfp-build-docker.yml
if: ${{ needs.release-please.outputs.continue == 'true' || github.event_name == 'workflow_dispatch' }}
with:
job-environment: 'build-docker'
suffix-tag: ${{ github.run_id }}
Expand All @@ -52,11 +72,13 @@ jobs:
secrets:
username: ${{ secrets.DOCKER_USERNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
needs: [ build ]
needs:
- release-please

build-docker-lite:
name: 'build sfp lite docker image'
uses: ./.github/workflows/sfp-build-docker.yml
if: ${{ needs.release-please.outputs.continue == 'true' || github.event_name == 'workflow_dispatch' }}
with:
job-environment: 'build-docker'
suffix-tag: ${{ github.run_id }}
Expand All @@ -66,7 +88,8 @@ jobs:
secrets:
username: ${{ secrets.DOCKER_USERNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
needs: [ build ]
needs:
- release-please

#Promotion Stages

Expand All @@ -77,11 +100,12 @@ jobs:
uses: ./.github/workflows/promotePackage.yml
with:
version: 'alpha'
pathToPackageJson: 'packages/sfp-cli/package.json'
pathToPackageJson: 'package.json'
environment: sfp-alpha
secrets:
npm-token: ${{ secrets.NPM_TOKEN }}
needs: [ build ]
needs:
- release-please

alpha-docker:
name: 'promote docker to alpha'
Expand Down Expand Up @@ -115,11 +139,12 @@ jobs:
uses: ./.github/workflows/promotePackage.yml
with:
version: 'beta'
pathToPackageJson: 'packages/sfp-cli/package.json'
pathToPackageJson: 'package.json'
environment: sfp-beta
secrets:
npm-token: ${{ secrets.NPM_TOKEN }}
needs: [ build ]
needs:
- release-please

beta-docker:
name: 'promote docker to beta'
Expand Down Expand Up @@ -155,11 +180,12 @@ jobs:
uses: ./.github/workflows/promotePackage.yml
with:
version: 'latest'
pathToPackageJson: 'packages/sfp-cli/package.json'
pathToPackageJson: 'package.json'
environment: sfp-prod
secrets:
npm-token: ${{ secrets.NPM_TOKEN }}
needs: [ build ]
needs:
- release-please

prod-docker:
name: 'copy rc docker to prod'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- name: 'Install Dependencies'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sfp-build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

steps:

- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -70,8 +70,8 @@ jobs:

- name: 'Get package version and name'
run: |
echo "PKG_VERSION=$(jq -r ".version" packages/sfp-cli/package.json)" >> $GITHUB_ENV
RELEASE_NAME=$(jq -r ".release" packages/sfp-cli/package.json)
echo "PKG_VERSION=$(jq -r ".version" package.json)" >> $GITHUB_ENV
RELEASE_NAME=$(jq -r ".release" package.json)
RELEASE_NAME_AS_ARRAY=($RELEASE_NAME)
RELEASE_NAME=$(echo ${RELEASE_NAME_AS_ARRAY[0]} | cut -c1-3)${RELEASE_NAME_AS_ARRAY[1]}
echo "RELEASE_NAME=release-$RELEASE_NAME" >> $GITHUB_ENV
Expand Down
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "39.0.0"
}
14 changes: 14 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"packages": {
".": {
"changelog-path": "CHANGELOG.md",
"release-type": "node",
"bump-minor-pre-major": false,
"bump-patch-for-minor-pre-major": false,
"draft": false,
"prerelease": false,
"include-component-in-tag":false
}
},
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}

0 comments on commit 6312fdf

Please sign in to comment.