Skip to content

Add Slack Integration and Update Publish Process (@W-7953925) #110

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

Merged
merged 2 commits into from
Aug 13, 2020
Merged
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
72 changes: 55 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ version: 2.1
orbs:
win: circleci/windows@2.2.0
sfchangecase: salesforce/change-case-management@3
slack: circleci/slack@3.4.2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference - there's additional setup that has to take place for the slack integration. This is the guide I am following.

Section:

To get started with enabling notifications in Slack for a specific project, head to the Settings page for your project. Click on Slack Integration in the sidebar and follow the steps to setup Slack.


parameters:
publish:
type: boolean
default: false
publish-type:
type: string
default: patch

_refs:
defaults: &defaults
Expand Down Expand Up @@ -107,9 +116,13 @@ jobs:
shell: bash.exe
- store_test_results:
path: test-results
release:
publish:
<<: *defaults
steps:
- slack/notify:
channel: 'pdt_releases'
color: '#FFDEAD'
message: 'Starting Publish for SDR Library'
- add_ssh_keys: *ssh-config
- checkout
- restore_cache: *restore_cache
Expand All @@ -127,10 +140,12 @@ jobs:
- run:
name: Bump package version
command: |
yarn version --patch --no-git-tag-version
yarn version --<< pipeline.parameters.publish-type >> --no-git-tag-version
git add package.json
export RELEASE_TAG="$(node -pe "require('./package.json').version")"
git commit -m "[skip ci] Updated version $RELEASE_TAG"
echo "export RELEASE_VERSION=$RELEASE_TAG" >> $BASH_ENV
source $BASH_ENV
git commit -m "Updated version $RELEASE_TAG"
- run:
name: Set .npmrc
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
Expand All @@ -139,16 +154,24 @@ jobs:
- run:
name: Tag the release and push to repo
command: |
export RELEASE_TAG="$(node -pe "require('./package.json').version")"
git tag v${RELEASE_TAG}
git tag v${RELEASE_VERSION}
git push --tags
- sfchangecase/update:
location: REPO_LOCATION
release: GUS_RELEASE
- slack/notify:
channel: 'pdt_releases'
color: '#9bcd9b'
message: 'SDR Library v${RELEASE_VERSION} has been published to npm'
- slack/status:
channel: 'pdt_releases'
fail_only: true

workflows:
version: 2
'deploy-and-retrieve':
version: 2.1

commit-workflow:
unless: << pipeline.parameters.publish >>
jobs:
- node-latest
- node-12
Expand All @@ -160,13 +183,28 @@ workflows:
branches:
ignore: /.*/
- run-win-tests
- release:
filters:
branches:
only:
- main
requires:
- node-latest
- node-12
- node-10
- run-win-tests

publish-workflow:
when: << pipeline.parameters.publish >>
jobs:
- slack/approval-notification:
message: Pending Approval for Publish of SDRL (Source Deploy Retrieve Library)
channel: 'pdt_releases'
color: '#0E1111'
- node-latest
- node-12
- node-10
Copy link
Contributor Author

@sfsholden sfsholden Aug 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the cache job needed here as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 4 jobs restore the cache for themselves already I believe - is that what you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm referring to this piece here. I don't think it's needed, but wanted to pose the question just in case:

      - cache:
          filters:
            tags:
              only: /^v.*/
            branches:
              ignore: /.*/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's needed, at least not with that specific config

- run-win-tests
- hold: # Requires manual approval in Circle Ci
type: approval
- publish:
filters:
branches:
only:
- main
requires:
- node-latest
- node-12
- node-10
- run-win-tests
- hold
27 changes: 27 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Publish Local Dev Server",
"command": "./script/publish-workflow.sh",
"type": "shell",
"args": ["${input:circleCiId}", "${input:publishType}"]
}
],
"inputs": [
{
"id": "circleCiId",
"type": "promptString",
"description": "CircleCi Token"
},
{
"id": "publishType",
"type": "pickString",
"description": "Type of version to publish",
"options": ["minor", "patch", "major"],
"default": "patch"
}
]
}
15 changes: 15 additions & 0 deletions scripts/publish-workflow.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

# For publishing a different version, see the format below for adding a publish-type
# parameter:
# "publish-type": "minor"

CircleCIToken=$1
PublishType=$2
curl -v -u ${CircleCIToken}: -X POST --header "Content-Type: application/json" -d '{
"branch": "main",
"parameters": {
"publish": true,
"publish-type": "'"${PublishType}"'"
}
}' https://circleci.com/api/v2/project/gh/forcedotcom/source-deploy-retrieve/pipeline