|
1 | | -name: Create Release for tag |
| 1 | +name: Call Create Release for tag Workflow |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | tags: |
6 | 6 | - 'v*' |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - provide_changed_packages: |
10 | | - # see json juggling: https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#example-6 |
11 | | - # see https://stackoverflow.com/a/62953566/1348344 |
12 | | - runs-on: ubuntu-latest |
13 | | - |
14 | | - steps: |
15 | | - - name: Set Environment |
16 | | - run: | |
17 | | - echo "BUILD_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV |
18 | | - - uses: actions/checkout@v3 |
19 | | - |
20 | | - # load current composer.lock |
21 | | - - id: currentLock |
22 | | - name: Gather latest package information |
23 | | - run: | |
24 | | - OUT=$(jq --slurp '[.[].packages[] | select(.name | contains("ezsystems") or contains("ibexa")) | [.name, .version] | { name: (.[0]), version: .[1] }]' composer.lock) |
25 | | - echo "lock=$( echo "$OUT" | sed ':a;N;$!ba;s/\n//g' )" >> $GITHUB_OUTPUT |
26 | | - - name: Get previous last full release |
27 | | - id: prevfull |
28 | | - run: | |
29 | | - OUT=$(hub api /repos/${{ github.repository }}/releases | jq -r '[.[] | select(.tag_name | test("^(?!.*alpha|.*beta|.*rc).*$")) | .tag_name] | sort_by(.) | last') |
30 | | - echo "tag=$( echo "$OUT" )" >> $GITHUB_OUTPUT |
31 | | - env: |
32 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
33 | | - |
34 | | - - name: Get previous release tag based on type |
35 | | - id: prevrelease |
36 | | - uses: ibexa/version-logic-action@master |
37 | | - with: |
38 | | - currentTag: ${{ env.BUILD_TAG }} |
39 | | - prevFullTag: ${{ steps.prevfull.outputs.tag }} |
40 | | - |
41 | | - # checkout previous tag |
42 | | - - uses: actions/checkout@v3 |
43 | | - with: |
44 | | - ref: ${{ steps.prevrelease.outputs.previousTag }} |
45 | | - |
46 | | - # load previous composer.lock |
47 | | - - id: previousLock |
48 | | - name: Gather previous package information |
49 | | - run: | |
50 | | - OUT=$(jq --slurp '[.[].packages[] | select(.name | contains("ezsystems") or contains("ibexa")) | [.name, .version] | { name: (.[0]), version: .[1] }]' composer.lock) |
51 | | - echo "lock=$( echo "$OUT" | sed ':a;N;$!ba;s/\n//g' )" >> $GITHUB_OUTPUT |
52 | | - # do some magic comparing those outputs |
53 | | - - id: output_data |
54 | | - name: Do comparison and output JSON with changes |
55 | | - run: | |
56 | | - FILE1=$(mktemp) |
57 | | - FILE2=$(mktemp) |
58 | | - cat > $FILE1 <<'EOF' |
59 | | - ${{ steps.previousLock.outputs.lock }} |
60 | | - EOF |
61 | | - cat > $FILE2 <<'EOF' |
62 | | - ${{ steps.currentLock.outputs.lock }} |
63 | | - EOF |
64 | | - # Get only changed packages and sort versions in ascending order |
65 | | - # Step 1: Merge composer.json from two versions, grouping by .name |
66 | | - # Step 2: Take .versions key and remove duplicate versions (means this bundle did not change) |
67 | | - # Step 3: Select only those bundles that have more than 1 version in .versions |
68 | | - # Step 4: Sort versions |
69 | | - # Step 5: (outer brackets) Wrap that into JSON list of objects |
70 | | - # Note: zzzz is added as an additional suffix to properly sort out alpha/beta/etc pre-releases (v2.5.1-alphazzzz < v2.5.1zzzz) |
71 | | - OUT=$(jq -s 'flatten | group_by(.name)' $FILE1 $FILE2 | jq -s '[ .[][] | {name: (.[0].name), versions: [ .[0].version, .[1].version ] | unique} | select(.versions | length > 1) ] | .[].versions |= sort_by( . + "zzzz" | [scan("[0-9]+|[a-z]+")] | map(tonumber? // .) )') |
72 | | - echo "matrix=$( echo "$OUT" | sed ':a;N;$!ba;s/\n//g' )" >> $GITHUB_OUTPUT |
73 | | - # this step is needed, so the output gets to the next defined job |
74 | | - outputs: |
75 | | - matrix: ${{ steps.output_data.outputs.matrix }} |
76 | | - |
77 | | - get_package_changelogs: |
78 | | - needs: provide_changed_packages |
79 | | - |
80 | | - runs-on: ubuntu-latest |
81 | | - |
82 | | - steps: |
83 | | - - name: Set Environment |
84 | | - run: | |
85 | | - echo "BUILD_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV |
86 | | - - name: Generate token |
87 | | - id: generate_token |
88 | | - uses: tibdex/github-app-token@v1 |
89 | | - with: |
90 | | - app_id: ${{ secrets.AUTOMATION_CLIENT_ID }} |
91 | | - installation_id: ${{ secrets.AUTOMATION_CLIENT_INSTALLATION }} |
92 | | - private_key: ${{ secrets.AUTOMATION_CLIENT_SECRET }} |
93 | | - - name: Get previous release tag based on type |
94 | | - id: prevrelease |
95 | | - uses: ibexa/version-logic-action@master |
96 | | - with: |
97 | | - currentTag: ${{ env.BUILD_TAG }} |
98 | | - |
99 | | - - name: Checkout Generator |
100 | | - uses: actions/checkout@v3 |
101 | | - with: |
102 | | - repository: ibexa/changelog-generator-action |
103 | | - ref: v2 |
104 | | - |
105 | | - - name: Setup Python environment |
106 | | - uses: actions/setup-python@v4 |
107 | | - with: |
108 | | - python-version: '3.x' |
109 | | - |
110 | | - - name: Install pygithub & jira |
111 | | - run: | |
112 | | - pip install pygithub jira github-action-utils |
113 | | - - name: Run generator in a loop |
114 | | - id: generator |
115 | | - env: |
116 | | - INPUT_GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} |
117 | | - INPUT_JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }} |
118 | | - run: | |
119 | | - cat > input.json <<'EOF' |
120 | | - ${{ needs.provide_changed_packages.outputs.matrix }} |
121 | | - EOF |
122 | | - export INPUT_BARE=True |
123 | | - echo "${{ github.repository }} ${{ env.BUILD_TAG }} change log" >> generator_output |
124 | | - echo "" >> generator_output |
125 | | - echo "Changes since ${{ steps.prevrelease.outputs.previousTag }}" >> generator_output |
126 | | - echo "" >> generator_output |
127 | | - jq -c '.[]' input.json | while read i; do |
128 | | - export GITHUB_REPOSITORY=$(jq -r '.name' <<< "$i") |
129 | | - export INPUT_PREVIOUSTAG=$(jq -r '.versions[0]' <<< "$i") |
130 | | - export INPUT_CURRENTTAG=$(jq -r '.versions[1]' <<< "$i") |
131 | | - echo Running against $GITHUB_REPOSITORY |
132 | | - echo -n "## " >> generator_output |
133 | | - python main.py >> generator_output |
134 | | - echo '' >> generator_output |
135 | | - done |
136 | | - echo "CHANGELOG_OUTPUT<<EOF" >> $GITHUB_ENV |
137 | | - echo "$(cat generator_output)" >> $GITHUB_ENV |
138 | | - echo "EOF" >> $GITHUB_ENV |
139 | | - - name: Create Release |
140 | | - id: create_release |
141 | | - uses: zendesk/action-create-release@v1 |
142 | | - with: |
143 | | - tag_name: ${{ env.BUILD_TAG }} |
144 | | - body: | |
145 | | - ${{ env.CHANGELOG_OUTPUT }} |
146 | | - env: |
147 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
148 | | - |
149 | | - - name: Archive markdown |
150 | | - uses: actions/upload-artifact@v3 |
151 | | - with: |
152 | | - name: changelogs |
153 | | - path: generator_output |
| 9 | + create_release_for_tag: |
| 10 | + uses: ibexa/gh-workflows/.github/workflows/release.yml@main |
| 11 | + secrets: |
| 12 | + AUTOMATION_CLIENT_ID: ${{ secrets.AUTOMATION_CLIENT_ID }} |
| 13 | + AUTOMATION_CLIENT_INSTALLATION: ${{ secrets.AUTOMATION_CLIENT_INSTALLATION }} |
| 14 | + AUTOMATION_CLIENT_SECRET: ${{ secrets.AUTOMATION_CLIENT_SECRET }} |
| 15 | + JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }} |
0 commit comments