Skip to content
This repository was archived by the owner on Sep 8, 2022. It is now read-only.

Commit 26f28e3

Browse files
author
Alexander Melnyk
authored
chore: update workflow with new projen version (#12)
* chore: update workflow with new projen version * chore: change back to 0.0.0 in jsii
1 parent 4b5af04 commit 26f28e3

File tree

4 files changed

+171
-82
lines changed

4 files changed

+171
-82
lines changed

.github/workflows/build.yml

Lines changed: 109 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ jobs:
66
build:
77
runs-on: ubuntu-latest
88
permissions:
9-
checks: write
109
contents: write
11-
actions: write
10+
outputs:
11+
self_mutation_happened: ${{ steps.self_mutation.outputs.self_mutation_happened }}
1212
env:
1313
CI: "true"
1414
steps:
@@ -17,39 +17,119 @@ jobs:
1717
with:
1818
ref: ${{ github.event.pull_request.head.ref }}
1919
repository: ${{ github.event.pull_request.head.repo.full_name }}
20-
- name: Set git identity
21-
run: |-
22-
git config user.name "github-actions"
23-
git config user.email "[email protected]"
2420
- name: Setup Node.js
2521
uses: actions/[email protected]
2622
with:
27-
node-version: "14"
23+
node-version: 14
2824
- name: Install dependencies
29-
run: yarn install --check-files --frozen-lockfile
25+
run: yarn install --check-files
3026
- name: give user docker permission so we can run tests
3127
run: sudo chown $(whoami) /var/run/docker.sock
3228
- name: build
3329
run: npx projen build
34-
- name: Check for changes
35-
id: git_diff
36-
run: git diff --exit-code || echo "::set-output name=has_changes::true"
37-
- if: steps.git_diff.outputs.has_changes
38-
name: Commit and push changes (if changed)
39-
run: 'git add . && git commit -m "chore: self mutation" && git push origin
40-
HEAD:${{ github.event.pull_request.head.ref }}'
41-
- if: steps.git_diff.outputs.has_changes
42-
name: Update status check (if changed)
43-
run: gh api -X POST /repos/${{ github.event.pull_request.head.repo.full_name
44-
}}/check-runs -F name="build" -F head_sha="$(git rev-parse HEAD)" -F
45-
status="completed" -F conclusion="success"
46-
env:
47-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48-
- if: steps.git_diff.outputs.has_changes
49-
name: Cancel workflow (if changed)
50-
run: gh api -X POST /repos/${{ github.event.pull_request.head.repo.full_name
51-
}}/actions/runs/${{ github.run_id }}/cancel
52-
env:
53-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
- id: self_mutation
31+
name: Find mutations
32+
run: >-
33+
git add .
34+
35+
git diff --staged --patch --exit-code > .repo.patch || echo "::set-output name=self_mutation_happened::true"
36+
- if: steps.self_mutation.outputs.self_mutation_happened
37+
name: Upload patch
38+
uses: actions/upload-artifact@v2
39+
with:
40+
name: .repo.patch
41+
path: .repo.patch
42+
- name: Fail build on mutation
43+
if: steps.self_mutation.outputs.self_mutation_happened
44+
run: >-
45+
echo "::error::Files were changed during build (see build log). If
46+
this was triggered from a fork, you will need to update your branch."
47+
48+
cat .repo.patch
49+
50+
exit 1
51+
- name: Upload artifact
52+
uses: actions/[email protected]
53+
with:
54+
name: build-artifact
55+
path: dist
5456
container:
55-
image: jsii/superchain:1-buster-slim
57+
image: jsii/superchain:1-buster-slim-node14
58+
self-mutation:
59+
needs: build
60+
runs-on: ubuntu-latest
61+
permissions:
62+
contents: write
63+
if: always() && needs.build.outputs.self_mutation_happened &&
64+
!(github.event.pull_request.head.repo.full_name != github.repository)
65+
steps:
66+
- name: Checkout
67+
uses: actions/checkout@v2
68+
with:
69+
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
70+
ref: ${{ github.event.pull_request.head.ref }}
71+
repository: ${{ github.event.pull_request.head.repo.full_name }}
72+
- name: Download patch
73+
uses: actions/download-artifact@v2
74+
with:
75+
name: .repo.patch
76+
path: ${{ runner.temp }}
77+
- name: Apply patch
78+
run: '[ -s ${{ runner.temp }}/.repo.patch ] && git apply ${{ runner.temp
79+
}}/.repo.patch || echo "Empty patch. Skipping."'
80+
- name: Set git identity
81+
run: |-
82+
git config user.name "github-actions"
83+
git config user.email "[email protected]"
84+
- name: Push changes
85+
run: |-2
86+
git add .
87+
git commit -m -s "chore: self mutation"
88+
git push origin HEAD:${{ github.event.pull_request.head.ref }}
89+
package-js:
90+
needs: build
91+
runs-on: ubuntu-latest
92+
permissions: {}
93+
if: "! needs.build.outputs.self_mutation_happened"
94+
steps:
95+
- uses: actions/setup-node@v2
96+
with:
97+
node-version: 14.x
98+
- name: Download build artifacts
99+
uses: actions/download-artifact@v2
100+
with:
101+
name: build-artifact
102+
path: dist
103+
- name: Prepare Repository
104+
run: mv dist .repo
105+
- name: Install Dependencies
106+
run: cd .repo && yarn install --check-files --frozen-lockfile
107+
- name: Create js artifact
108+
run: cd .repo && npx projen package:js
109+
- name: Collect js Artifact
110+
run: mv .repo/dist dist
111+
package-python:
112+
needs: build
113+
runs-on: ubuntu-latest
114+
permissions: {}
115+
if: "! needs.build.outputs.self_mutation_happened"
116+
steps:
117+
- uses: actions/setup-node@v2
118+
with:
119+
node-version: 14.x
120+
- uses: actions/setup-python@v2
121+
with:
122+
python-version: 3.x
123+
- name: Download build artifacts
124+
uses: actions/download-artifact@v2
125+
with:
126+
name: build-artifact
127+
path: dist
128+
- name: Prepare Repository
129+
run: mv dist .repo
130+
- name: Install Dependencies
131+
run: cd .repo && yarn install --check-files --frozen-lockfile
132+
- name: Create python artifact
133+
run: cd .repo && npx projen package:python
134+
- name: Collect python Artifact
135+
run: mv .repo/dist dist

.github/workflows/release.yml

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Setup Node.js
2626
uses: actions/[email protected]
2727
with:
28-
node-version: "14"
28+
node-version: 14
2929
- name: Install dependencies
3030
run: yarn install --check-files --frozen-lockfile
3131
- name: give user docker permission so we can run tests
@@ -40,10 +40,10 @@ jobs:
4040
if: ${{ steps.git_remote.outputs.latest_commit == github.sha }}
4141
uses: actions/[email protected]
4242
with:
43-
name: dist
43+
name: build-artifact
4444
path: dist
4545
container:
46-
image: jsii/superchain:1-buster-slim
46+
image: jsii/superchain:1-buster-slim-node14
4747
release_github:
4848
name: Publish to GitHub Releases
4949
needs: release
@@ -52,11 +52,18 @@ jobs:
5252
contents: write
5353
if: needs.release.outputs.latest_commit == github.sha
5454
steps:
55+
- uses: actions/setup-node@v2
56+
with:
57+
node-version: 14.x
5558
- name: Download build artifacts
5659
uses: actions/download-artifact@v2
5760
with:
58-
name: dist
61+
name: build-artifact
5962
path: dist
63+
- name: Prepare Repository
64+
run: mv dist .repo
65+
- name: Collect GitHub Metadata
66+
run: mv .repo/dist dist
6067
- name: Release
6168
run: errout=$(mktemp); gh release create $(cat dist/releasetag.txt) -R
6269
$GITHUB_REPOSITORY -F dist/changelog.md -t $(cat dist/releasetag.txt)
@@ -75,19 +82,28 @@ jobs:
7582
contents: read
7683
if: needs.release.outputs.latest_commit == github.sha
7784
steps:
85+
- uses: actions/setup-node@v2
86+
with:
87+
node-version: 14.x
7888
- name: Download build artifacts
7989
uses: actions/download-artifact@v2
8090
with:
81-
name: dist
91+
name: build-artifact
8292
path: dist
93+
- name: Prepare Repository
94+
run: mv dist .repo
95+
- name: Install Dependencies
96+
run: cd .repo && yarn install --check-files --frozen-lockfile
97+
- name: Create js artifact
98+
run: cd .repo && npx projen package:js
99+
- name: Collect js Artifact
100+
run: mv .repo/dist dist
83101
- name: Release
84102
run: npx -p jsii-release@latest jsii-release-npm
85103
env:
86104
NPM_DIST_TAG: latest
87105
NPM_REGISTRY: registry.npmjs.org
88106
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
89-
container:
90-
image: jsii/superchain:1-buster-slim-node14
91107
release_pypi:
92108
name: Publish to PyPI
93109
needs: release
@@ -96,15 +112,27 @@ jobs:
96112
contents: read
97113
if: needs.release.outputs.latest_commit == github.sha
98114
steps:
115+
- uses: actions/setup-node@v2
116+
with:
117+
node-version: 14.x
118+
- uses: actions/setup-python@v2
119+
with:
120+
python-version: 3.x
99121
- name: Download build artifacts
100122
uses: actions/download-artifact@v2
101123
with:
102-
name: dist
124+
name: build-artifact
103125
path: dist
126+
- name: Prepare Repository
127+
run: mv dist .repo
128+
- name: Install Dependencies
129+
run: cd .repo && yarn install --check-files --frozen-lockfile
130+
- name: Create python artifact
131+
run: cd .repo && npx projen package:python
132+
- name: Collect python Artifact
133+
run: mv .repo/dist dist
104134
- name: Release
105135
run: npx -p jsii-release@latest jsii-release-pypi
106136
env:
107137
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
108138
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
109-
container:
110-
image: jsii/superchain:1-buster-slim-node14

.github/workflows/upgrade-main.yml

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".
2-
31
name: upgrade-main
42
on:
53
workflow_dispatch: {}
@@ -12,69 +10,65 @@ jobs:
1210
permissions:
1311
contents: read
1412
outputs:
15-
conclusion: ${{ steps.build.outputs.conclusion }}
13+
patch_created: ${{ steps.create_patch.outputs.patch_created }}
1614
steps:
1715
- name: Checkout
1816
uses: actions/checkout@v2
1917
with:
2018
ref: main
21-
- name: Set git identity
22-
run: |-
23-
git config user.name "github-actions"
24-
git config user.email "[email protected]"
2519
- name: Setup Node.js
2620
uses: actions/[email protected]
2721
with:
28-
node-version: "14"
22+
node-version: 14
2923
- name: Install dependencies
3024
run: yarn install --check-files --frozen-lockfile
3125
- name: Upgrade dependencies
3226
run: npx projen upgrade
33-
- name: Build
34-
id: build
35-
run: npx projen build && echo "::set-output name=conclusion::success" || echo
36-
"::set-output name=conclusion::failure"
37-
- name: Create Patch
38-
run: |-
27+
- id: create_patch
28+
name: Find mutations
29+
run: >-
3930
git add .
40-
git diff --patch --staged > .upgrade.tmp.patch
41-
- name: Upload patch
31+
32+
git diff --staged --patch --exit-code > .repo.patch || echo "::set-output name=patch_created::true"
33+
- if: steps.create_patch.outputs.patch_created
34+
name: Upload patch
4235
uses: actions/upload-artifact@v2
4336
with:
44-
name: .upgrade.tmp.patch
45-
path: .upgrade.tmp.patch
37+
name: .repo.patch
38+
path: .repo.patch
4639
container:
47-
image: jsii/superchain:1-buster-slim
40+
image: jsii/superchain:1-buster-slim-node14
4841
pr:
4942
name: Create Pull Request
5043
needs: upgrade
5144
runs-on: ubuntu-latest
5245
permissions:
5346
contents: write
5447
pull-requests: write
55-
checks: write
48+
if: ${{ needs.upgrade.outputs.patch_created }}
5649
steps:
5750
- name: Checkout
5851
uses: actions/checkout@v2
5952
with:
53+
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
6054
ref: main
61-
- name: Set git identity
62-
run: |-
63-
git config user.name "github-actions"
64-
git config user.email "[email protected]"
6555
- name: Download patch
6656
uses: actions/download-artifact@v2
6757
with:
68-
name: .upgrade.tmp.patch
58+
name: .repo.patch
6959
path: ${{ runner.temp }}
7060
- name: Apply patch
71-
run: '[ -s ${{ runner.temp }}/.upgrade.tmp.patch ] && git apply ${{ runner.temp
72-
}}/.upgrade.tmp.patch || echo "Empty patch. Skipping."'
61+
run: '[ -s ${{ runner.temp }}/.repo.patch ] && git apply ${{ runner.temp
62+
}}/.repo.patch || echo "Empty patch. Skipping."'
63+
- name: Set git identity
64+
run: |-
65+
git config user.name "github-actions"
66+
git config user.email "[email protected]"
7367
- name: Create Pull Request
7468
id: create-pr
7569
uses: peter-evans/create-pull-request@v3
7670
with:
77-
token: ${{ secrets.GITHUB_TOKEN }}
71+
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
7872
commit-message: >-
7973
chore(deps): upgrade dependencies
8074
@@ -105,16 +99,3 @@ jobs:
10599
author: github-actions <[email protected]>
106100
committer: github-actions <[email protected]>
107101
signoff: true
108-
- name: Update status check
109-
if: steps.create-pr.outputs.pull-request-url != ''
110-
run: "curl -i --fail -X POST -H \"Accept: application/vnd.github.v3+json\" -H
111-
\"Authorization: token ${GITHUB_TOKEN}\"
112-
https://api.github.com/repos/${{ github.repository }}/check-runs -d
113-
'{\"name\":\"build\",\"head_sha\":\"github-actions/upgrade-main\",\"s\
114-
tatus\":\"completed\",\"conclusion\":\"${{
115-
needs.upgrade.outputs.conclusion }}\",\"output\":{\"title\":\"Created
116-
via the upgrade-main workflow.\",\"summary\":\"Action run URL:
117-
https://github.com/${{ github.repository }}/actions/runs/${{
118-
github.run_id }}\"}}'"
119-
env:
120-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.jsii

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,6 +3029,6 @@
30293029
"symbolId": "src/lambda-powertools-layer:PowertoolsLayerProps"
30303030
}
30313031
},
3032-
"version": "2.0.1",
3033-
"fingerprint": "2+Mxho53JarS/CuSO41JV12xFEM9raTO6d5PO/NOmW8="
3032+
"version": "0.0.0",
3033+
"fingerprint": "ZOXqlBA8ovzkzVpQUPgfqo7z7wPVh6CZrwedIJhp3F8="
30343034
}

0 commit comments

Comments
 (0)