-
Notifications
You must be signed in to change notification settings - Fork 25
99 lines (93 loc) · 3.57 KB
/
release-Production-workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Release plugin to production
on:
pull_request:
types:
- closed
branches:
- 'main'
paths-ignore:
- '**.md'
- '**.yml'
- 'examples/**'
- 'docs/**'
- 'assets/**'
jobs:
# Pre-Release-To-Prod:
# if: github.event.pull_request.merged == true
# uses: ./.github/workflows/pre-release-workflow.yml
# secrets: inherit
Build-Sample-Apps:
# needs: [ Pre-Release-To-Prod ]
uses: ./.github/workflows/build-apps-workflow.yml
secrets: inherit
Deploy-To-Production:
needs: [ Build-Sample-Apps ]
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install dependency
run: |
npm i rimraf
- name: Login to Github
env:
COMMIT_AUTHOR: ${{ secrets.CI_COMMIT_AUTHOR }}
COMMIT_EMAIL: ${{ secrets.CI_COMMIT_EMAIL }}
run: |
git config --global user.name $COMMIT_AUTHOR
git config --global user.email $COMMIT_EMAIL
- uses: mdecoleman/[email protected]
id: vars
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Determine release tag and release branch
run: |
TAG=$(echo "${{ steps.vars.outputs.branch }}" | grep -Eo '[0-9]+.[0-9]+.[0-9]+')
echo "PLUGIN_VERSION=$TAG" >> $GITHUB_ENV
echo "RELEASE_BRANCH_NAME=${{ steps.vars.outputs.branch }}" >> $GITHUB_ENV
echo "push new release >> $TAG"
- name: "Create release"
env:
TAG: ${{env.PLUGIN_VERSION}}
uses: "actions/github-script@v5"
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
try {
await github.rest.repos.createRelease({
draft: false,
generate_release_notes: false,
name: process.env.TAG,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.TAG
});
} catch (error) {
core.setFailed(error.message);
}
- name: Push to NPM
env:
CI_NPM_TOKEN: ${{ secrets.CI_NPM_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=$CI_NPM_TOKEN" > ~/.npmrc
npm run build
npm publish
- name: Generate and send slack report
env:
SLACK_TOKEN: ${{ secrets.CI_SLACK_TOKEN }}
JIRA_TOKEN: ${{ secrets.CI_JIRA_TOKEN }}
JIRA_FIXED_VERSION: "Capacitor SDK v${{env.PLUGIN_VERSION}}"
run: |
ANDROID_SDK_VERSION=`cat package.json | jq .androidSdkVersion`
IOS_SDK_VERSION=`cat package.json | jq .iosSdkVersion`
PLUGIN_VERSION=`cat package.json | jq .version`
BUILD_NUMBER=`cat package.json | jq .buildNumber`
chmod +x .github/workflows/scripts/releaseNotesGenerator.sh
.github/workflows/scripts/releaseNotesGenerator.sh $JIRA_TOKEN "$JIRA_FIXED_VERSION"
CHANGES=$(cat "$JIRA_FIXED_VERSION-releasenotes".txt)
curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"$JIRA_FIXED_VERSION"'", "deploy_type": "Production", "install_tag": "latest", "git_branch": "'"$RELEASE_BRANCH_NAME"'", "changes_and_fixes": "'"$CHANGES"'", "plugin_version": "'"${{env.PLUGIN_VERSION}}"'", "android_dependency": "'"$ANDROID_SDK_VERSION"'", "ios_dependency": "'"$IOS_SDK_VERSION"'"}' "$SLACK_TOKEN"