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

Automated packaing #5

Closed
wants to merge 7 commits into from
Closed
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
46 changes: 46 additions & 0 deletions .github/workflows/pr-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Pull Request to Develop

on:
pull_request:
branches: [ dev ]

jobs:
validate_pull_request:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install Salesforce CLI
run: |
wget https://developer.salesforce.com/media/salesforce-cli/sf/channels/stable/sf-linux-x64.tar.xz
mkdir sfdx-cli
tar xJf sf-linux-amd64.tar.xz -C sfdx-cli --strip-components 1
./sfdx-cli/install

- name: Install jq
run: |
sudo apt-get install jq

- name: Populate auth file
shell: bash
run: 'echo ${{secrets.DEVHUB_SFDX_URL}} > ./DEVHUB_SFDX_URL.txt'

- name: Authenticate Dev Hub
run: 'sfdx force:auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d'

- name: Create scratch org
run: 'sfdx force:org:create -f config/project-scratch-def.json -a ci_scratch -s -d 1'

- name: Push source to scratch org
run: 'sfdx force:source:push'

- name: Check code coverage
run: |
sfdx force:apex:test:run --codecoverage --resultformat json --synchronous --testlevel RunLocalTests --wait 10 > tests.json
coverage=$(jq .result.summary.orgWideCoverage tests.json | grep -Eo "[[:digit:]]+")
test $coverage -ge 75

- name: Delete scratch org
if: always()
run: 'sf org delete scratch -p -o ci_scratch'
51 changes: 51 additions & 0 deletions .github/workflows/push-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Create pre-release version

on:
push:
branches: [ dev ]

jobs:
pre_release:
# The type of runner that the job will run on
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install Salesforce CLI
run: |
wget https://developer.salesforce.com/media/salesforce-cli/sf/channels/stable/sf-linux-x64.tar.xz
mkdir sfdx-cli
tar xJf sfdx-linux-amd64.tar.xz -C sfdx-cli --strip-components 1
./sfdx-cli/install

- name: Populate auth file
shell: bash
run: 'echo ${{secrets.DEVHUB_SFDX_URL}} > ./DEVHUB_SFDX_URL.txt'

- name: Authenticate Dev Hub
run: 'sfdx force:auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d'

- name: Create new version
run: |
sfdx force:package:version:create -x -p "Kicksaw UAT App" -w 60 --codecoverage
new_version_id=$(grep -o "04t[[:alnum:]]\{15\}" sfdx-project.json | tail -n1)
echo "version_id=${new_version_id}" >> $GITHUB_ENV

- name: Check code coverage
run: |
test $(sfdx force:package:version:report -p "$version_id" --json | jq .result.HasPassedCodeCoverageCheck) = 'true'

- name: Install new version in Dev Hub
run: |
sfdx force:package:install -p "$version_id" -u devhub --wait 10 --publishwait 10

- name: Store new version id
run: |
sed -i -e "s/04t[[:alnum:]]\{15\}/${version_id}/" README.md
git config user.name "release[bot]"
git config user.email "<>"
git add README.md
git add sfdx-project.json
git commit -m "Updating new pre-release version"
git push
45 changes: 45 additions & 0 deletions .github/workflows/push-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish new release

on:
push:
branches: [ master ]

jobs:
publish_release:
# The type of runner that the job will run on
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install Salesforce CLI
run: |
wget https://developer.salesforce.com/media/salesforce-cli/sf/channels/stable/sf-linux-x64.tar.xz
mkdir sfdx-cli
tar xJf sfdx-linux-amd64.tar.xz -C sfdx-cli --strip-components 1
./sfdx-cli/install

- name: Install jq
run: |
sudo apt-get install jq

- name: Populate auth file
shell: bash
run: 'echo ${{secrets.DEVHUB_SFDX_URL}} > ./DEVHUB_SFDX_URL.txt'

- name: Authenticate Dev Hub
run: 'sfdx force:auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d'

- name: Promote latest version
run: |
version_id=$(grep -o "04t[[:alnum:]]\{15\}" sfdx-project.json | tail -n1)
sfdx force:package:version:promote -p "$version_id" --noprompt

- name: Tag new release
run: |
tag_name=$(jq ".packageDirectories[0].versionName" sfdx-project.json | tr -d '"'| tr -d ' ')
pkg_name=$(jq ".packageDirectories[0].package" sfdx-project.json | tr -d '"')
git config user.name "release[bot]"
git config user.email "<>"
git tag -a "$tag_name" -m "$pkg_name $tag_name"
git push origin "$tag_name"
Loading