Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: matrix job to do aws region based releases #11

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 69 additions & 16 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,14 @@ on:
workflow_dispatch:

jobs:
release:
fetch-regions:
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
permissions:
contents: write
id-token: write
pull-requests: write

outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: checkout
uses: actions/checkout@v4

- name: build
run: make sam-build-all

- name: Setup AWS credentials
uses: aws-actions/configure-aws-credentials@v4.0.1
with:
Expand All @@ -31,37 +24,97 @@ jobs:
- name: AWS Info
run: aws sts get-caller-identity

- name: Fetch available AWS regions
id: fetch-regions
run: |
regions=$(aws ec2 describe-regions --query "Regions[].RegionName" --output text | tr '\t' '\n' | jq -R -s -c 'split("\n")[:-1]')
echo "Regions: $regions"
echo "regions_json=$regions" >> "$GITHUB_ENV"

- name: Set Matrix for aws-release job
id: set-matrix
run: echo "matrix=${regions_json}" >> "$GITHUB_OUTPUT"

github-release:
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
outputs:
version: ${{ steps.prerelease.outputs.release-version }}
steps:
- name: checkout
uses: actions/checkout@v4

- name: github release (beta)
id: prerelease
if: github.event_name == 'push'
id: prerelease
uses: ahmadnassri/action-semantic-release@v2
with:
config: ${{ github.workspace }}/.releaserc.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: github release (stable)
id: fullrelease
if: github.event_name == 'workflow_dispatch'
id: fullrelease
uses: ahmadnassri/action-semantic-release@v2
with:
config: ${{ github.workspace }}/.releaserc-release.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set version for aws-release job
id: set-version
run: |
version=${{ steps.prerelease.outputs.release-version }}
if [ -z "$version" ]; then
version=${{ steps.fullrelease.outputs.release-version }}
fi
echo "version=$version" >> "$GITHUB_OUTPUT"

aws-release:
needs: [fetch-regions, github-release]
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
strategy:
matrix:
region: ${{fromJson(needs.fetch-regions.outputs.matrix)}}
permissions:
contents: write
id-token: write
pull-requests: write

steps:
- name: checkout
uses: actions/checkout@v4

- name: build
run: make sam-build-all

- name: Setup AWS credentials
uses: aws-actions/configure-aws-credentials@v4.0.1
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-west-2

- name: AWS Info
run: aws sts get-caller-identity

- name: aws sam release (versioned)
run: make sam-package-all-regions
run: make sam-package-all
env:
VERSION: ${{ (steps.prerelease.outputs.release-version != '') && steps.prerelease.outputs.release-version || steps.fullrelease.outputs.release-version }}
VERSION: ${{ needs.github-release.outputs.version }}
AWS_REGION: ${{ matrix.region }}

- name: aws sam release (beta)
if: github.event_name == 'push'
run: make sam-package-all-regions
run: make sam-package-all
env:
VERSION: beta
AWS_REGION: ${{ matrix.region }}

- name: aws sam release (stable)
if: github.event_name == 'workflow_dispatch'
run: make sam-package-all-regions
run: make sam-package-all
env:
VERSION: latest
AWS_REGION: ${{ matrix.region }}
Loading