-
Notifications
You must be signed in to change notification settings - Fork 9
82 lines (82 loc) · 2.77 KB
/
package-release.yaml
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
name: Create package release
on:
push:
branches: [ main ]
tags:
- '*'
jobs:
prepare:
name: 'Check packages for release'
runs-on: ubuntu-latest
outputs:
output: ${{ steps.set_env.outputs.test }}
steps:
- name: Checkout the repository
uses: actions/checkout@main
with:
ref: 'main'
- name: fetch tags
run: git fetch --tags
- name: collect integrations names
run: |
cd common/
echo "PACKAGE=$(ls | jq --raw-input . | jq --slurp . | jq tostring)" >> $GITHUB_ENV
- name: set tag
run: echo "TAGS=$(git tag --points-at | jq --raw-input . | jq --slurp . | jq tostring)" >> $GITHUB_ENV
- id: output-tags
uses: actions/github-script@master
with:
script: |
const { PACKAGE, TAGS } = process.env;
console.log(PACKAGE);
console.log(TAGS);
const package = JSON.parse(JSON.parse(PACKAGE));
const tags = JSON.parse(JSON.parse(TAGS));
const selectedTags = tags.filter(it => package.includes(it.trim().split('/')[1]?.split('@')[0]))
return JSON.stringify(JSON.stringify(selectedTags))
result-encoding: string
- name: print var
run: echo ${{steps.output-tags.outputs.result}}
- name: set
id: set_env
run: echo "::set-output name=test::${{steps.output-tags.outputs.result}}"
release:
name: 'Packages release'
if: needs.prepare.outputs.output != '[]'
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix:
tag: ${{fromJSON(needs.prepare.outputs.output)}}
steps:
- name: Checkout the repository
uses: actions/checkout@main
with:
ref: 'main'
- name: set integration name
run: echo "PACKAGE_NAME=$(echo ${{ matrix.tag }} | awk -F'[/@]' '{print $3}' | sed 's/ *$//g')" >> $GITHUB_ENV
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: setup lerna
run: yarn setup
- name: print integration name
run: echo ${{ env.PACKAGE_NAME }}
- name: build
run: yarn build
# todo: publish to npm registry
# - name: Publish release
# run: yarn publish
# working-directory: common/${{env.PACKAGE_NAME}}
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Release Body
run: npx extract-changelog-release ${{ github.workspace }}/common/${{env.PACKAGE_NAME}}/CHANGELOG.md > RELEASE_BODY.md
- name: Publish the Release
uses: softprops/action-gh-release@v1
with:
body_path: RELEASE_BODY.md
tag_name: ${{ matrix.tag }}
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}