Skip to content

Commit

Permalink
change release flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Claude-GP committed Jan 29, 2024
1 parent 4a5d2d4 commit 2b9ff3e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 49 deletions.
78 changes: 32 additions & 46 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,51 @@ name: Release

on:
release:
types: [published]

env:
UPLOAD_LAMBDA: false
types: [prereleased, edited, released]

jobs:
# test:
# name: Test lambda function
# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v2

# - name: Install dependencies
# run: yarn install

# - name: Test
# run: yarn test

build-and-upload:
name: Build GitHub action and AWS lambda function
if: "false" # To be removed
build:
name: Build AWS lambda function
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
ref: "main"

- name: Install dependencies
run: yarn install

- name: Build lambda distribution
run: yarn dist

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Upload new build to AWS lambda
- name: Get release tag
id: ref
run: |
aws lambda update-function-code --function-name "$FUNCTION_ARN" --zip-file "fileb://$(pwd)/out/lambda.zip"
TAG=${REF#"$PREFIX"}
echo "::set-output name=tag::$TAG"
env:
FUNCTION_ARN: ${{ secrets.LAMBDA_FUNCTION_ARN }}
REF: ${{ github.ref }}
PREFIX: "refs/tags/"

test-new-version:
name: Test uploaded lambda
needs: build-and-upload
if: "false" # To be removed
runs-on: ubuntu-latest
- name: Update package.json version
run: |
tmp=$(mktemp)
jq '.version = "${{ steps.ref.outputs.tag }}"' package.json > "$tmp"
mv "$tmp" package.json
steps:
- uses: actions/checkout@v2
- name: Build lambda distribution
run: yarn dist

- name: Install dependencies
run: yarn install
- name: Setup GitHub git user
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Integration tests
run: yarn test
env:
LAMBDA_URL: ${{ secrets.LAMBDA_URL }}
- name: Push builds
run: |
git add package.json terraform/lambda.zip
git commit -m "Build app for release ${{ steps.ref.outputs.tag }}"
git push
- name: Move release tag to latest commit
run: |
git tag --force "${{ steps.ref.outputs.tag }}" $(git rev-parse HEAD)
git push --force --tags
5 changes: 2 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ on:
push:
branches:
- main
pull_request:

jobs:
terraform:
name: Validate Terraform code
runs-on: ubuntu-latest

env:
TERRAFORM_VERSION: 1.4.0
TERRAFORM_VERSION: 0.13.5
TERRAFORM_WORK_DIR: ./terraform

steps:
Expand Down Expand Up @@ -58,4 +57,4 @@ jobs:
run: yarn install

- name: Build lambda distribution
run: yarn dist
run: yarn dist

0 comments on commit 2b9ff3e

Please sign in to comment.