Skip to content

Commit 2b9ff3e

Browse files
committed
change release flow
1 parent 4a5d2d4 commit 2b9ff3e

File tree

2 files changed

+34
-49
lines changed

2 files changed

+34
-49
lines changed

.github/workflows/release.yml

Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,51 @@ name: Release
22

33
on:
44
release:
5-
types: [published]
6-
7-
env:
8-
UPLOAD_LAMBDA: false
5+
types: [prereleased, edited, released]
96

107
jobs:
11-
# test:
12-
# name: Test lambda function
13-
# runs-on: ubuntu-latest
14-
15-
# steps:
16-
# - uses: actions/checkout@v2
17-
18-
# - name: Install dependencies
19-
# run: yarn install
20-
21-
# - name: Test
22-
# run: yarn test
23-
24-
build-and-upload:
25-
name: Build GitHub action and AWS lambda function
26-
if: "false" # To be removed
8+
build:
9+
name: Build AWS lambda function
2710
runs-on: ubuntu-latest
2811

2912
steps:
3013
- uses: actions/checkout@v2
14+
with:
15+
ref: "main"
3116

3217
- name: Install dependencies
3318
run: yarn install
3419

35-
- name: Build lambda distribution
36-
run: yarn dist
37-
38-
- name: Configure AWS credentials
39-
uses: aws-actions/configure-aws-credentials@v1
40-
with:
41-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
42-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
43-
aws-region: ${{ secrets.AWS_REGION }}
44-
45-
- name: Upload new build to AWS lambda
20+
- name: Get release tag
21+
id: ref
4622
run: |
47-
aws lambda update-function-code --function-name "$FUNCTION_ARN" --zip-file "fileb://$(pwd)/out/lambda.zip"
23+
TAG=${REF#"$PREFIX"}
24+
echo "::set-output name=tag::$TAG"
4825
env:
49-
FUNCTION_ARN: ${{ secrets.LAMBDA_FUNCTION_ARN }}
26+
REF: ${{ github.ref }}
27+
PREFIX: "refs/tags/"
5028

51-
test-new-version:
52-
name: Test uploaded lambda
53-
needs: build-and-upload
54-
if: "false" # To be removed
55-
runs-on: ubuntu-latest
29+
- name: Update package.json version
30+
run: |
31+
tmp=$(mktemp)
32+
jq '.version = "${{ steps.ref.outputs.tag }}"' package.json > "$tmp"
33+
mv "$tmp" package.json
5634
57-
steps:
58-
- uses: actions/checkout@v2
35+
- name: Build lambda distribution
36+
run: yarn dist
5937

60-
- name: Install dependencies
61-
run: yarn install
38+
- name: Setup GitHub git user
39+
run: |
40+
git config user.name github-actions
41+
git config user.email [email protected]
6242
63-
- name: Integration tests
64-
run: yarn test
65-
env:
66-
LAMBDA_URL: ${{ secrets.LAMBDA_URL }}
43+
- name: Push builds
44+
run: |
45+
git add package.json terraform/lambda.zip
46+
git commit -m "Build app for release ${{ steps.ref.outputs.tag }}"
47+
git push
48+
49+
- name: Move release tag to latest commit
50+
run: |
51+
git tag --force "${{ steps.ref.outputs.tag }}" $(git rev-parse HEAD)
52+
git push --force --tags

.github/workflows/tests.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request:
87

98
jobs:
109
terraform:
1110
name: Validate Terraform code
1211
runs-on: ubuntu-latest
1312

1413
env:
15-
TERRAFORM_VERSION: 1.4.0
14+
TERRAFORM_VERSION: 0.13.5
1615
TERRAFORM_WORK_DIR: ./terraform
1716

1817
steps:
@@ -58,4 +57,4 @@ jobs:
5857
run: yarn install
5958

6059
- name: Build lambda distribution
61-
run: yarn dist
60+
run: yarn dist

0 commit comments

Comments
 (0)