Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .bun-version

This file was deleted.

29 changes: 0 additions & 29 deletions .changeset/README.md

This file was deleted.

16 changes: 0 additions & 16 deletions .changeset/config.json

This file was deleted.

52 changes: 33 additions & 19 deletions .github/actions/deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ inputs:
op-service-account-token:
description: "1Password service account token"
required: true
version:
description: "Application version to expose at runtime"
required: false
runs:
using: composite
steps:
Expand All @@ -21,6 +24,11 @@ runs:
with:
terraform_version: "1.14.5"

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v3
with:
Expand All @@ -44,6 +52,8 @@ runs:
SPOTIFY_CLIENT_ID: op://ci-cd/lho-lambda/SPOTIFY_CLIENT_ID
SPOTIFY_CLIENT_SECRET: op://ci-cd/lho-lambda/SPOTIFY_CLIENT_SECRET
SPOTIFY_REFRESH_TOKEN: op://ci-cd/lho-lambda/SPOTIFY_REFRESH_TOKEN
LASTFM_API_KEY: op://ci-cd/lho-lambda/LASTFM_API_KEY
LASTFM_USERNAME: op://ci-cd/lho-lambda/LASTFM_USERNAME
OP_ENV_FILE: ".env"

- name: Set Terraform variables
Expand All @@ -52,6 +62,8 @@ runs:
echo "TF_VAR_spotify_client_id=$SPOTIFY_CLIENT_ID" >> $GITHUB_ENV
echo "TF_VAR_spotify_client_secret=$SPOTIFY_CLIENT_SECRET" >> $GITHUB_ENV
echo "TF_VAR_spotify_refresh_token=$SPOTIFY_REFRESH_TOKEN" >> $GITHUB_ENV
echo "TF_VAR_lastfm_api_key=$LASTFM_API_KEY" >> $GITHUB_ENV
echo "TF_VAR_lastfm_username=$LASTFM_USERNAME" >> $GITHUB_ENV

- name: Terraform init
shell: bash
Expand All @@ -77,31 +89,33 @@ runs:
- name: Build functions for Lambda
shell: bash
run: |
docker run --rm \
--platform linux/amd64 \
-v "${{ github.workspace }}:/workspace" \
-w /workspace \
swift:6.1-amazonlinux2 \
bash -c "swift build -c release --static-swift-stdlib && \
cp .build/release/lambda .build/release/bootstrap && \
chmod 755 .build/release/bootstrap && \
mkdir -p .build/release/authorizer-package && \
cp .build/release/authorizer .build/release/authorizer-package/bootstrap && \
chmod 755 .build/release/authorizer-package/bootstrap"
sudo chown -R $(id -u):$(id -g) .build
dotnet publish src/Lho.Lambda/Lho.Lambda.csproj \
--configuration Release \
--runtime linux-x64 \
--self-contained false \
-p:PublishReadyToRun=true \
--output .build/release/lambda-package
dotnet publish src/Lho.Lambda.Authorizer/Lho.Lambda.Authorizer.csproj \
--configuration Release \
--runtime linux-x64 \
--self-contained false \
-p:PublishReadyToRun=true \
--output .build/release/authorizer-package

- name: Get version
id: version
shell: bash
env:
DEPLOY_VERSION: ${{ inputs.version }}
run: |
# Use VERSION env var if set (for pre-releases), otherwise read from package.json
if [ -n "$VERSION" ]; then
echo "Using provided version: $VERSION"
echo "APP_VERSION=$VERSION" >> $GITHUB_ENV
if [ -n "$DEPLOY_VERSION" ]; then
echo "Using provided version: $DEPLOY_VERSION"
echo "APP_VERSION=$DEPLOY_VERSION" >> $GITHUB_ENV
else
PKG_VERSION=$(jq -r .version package.json)
echo "Using package.json version: $PKG_VERSION"
echo "APP_VERSION=$PKG_VERSION" >> $GITHUB_ENV
SHORT_SHA="${GITHUB_SHA:0:7}"
APP_VERSION="${{ inputs.environment }}-${SHORT_SHA}"
echo "Using generated version: $APP_VERSION"
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
fi

- name: Terraform plan
Expand Down
31 changes: 12 additions & 19 deletions .github/actions/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,22 @@ runs:
run: git stash && git pull --rebase
shell: bash

- name: Setup Swift
uses: swift-actions/setup-swift@v3
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
swift-version: "6.1.0"
dotnet-version: "8.0.x"

- name: Resolve Swift dependencies
- name: Restore dependencies
shell: bash
run: swift package resolve
run: dotnet restore Lho.Lambda.slnx

- name: 🥟 Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version-file: ".bun-version"

- name: Setup Node
uses: actions/setup-node@v4.1.0
with:
node-version-file: .nvmrc

- name: Install dependencies
- name: Build
shell: bash
run: bun install
run: |
dotnet build src/Lho.Lambda/Lho.Lambda.csproj --no-restore
dotnet build src/Lho.Lambda.Authorizer/Lho.Lambda.Authorizer.csproj --no-restore
dotnet build src/Lho.Lambda.Local/Lho.Lambda.Local.csproj --no-restore

- name: Check commit message
- name: Test
shell: bash
run: bun commitlint --from=HEAD^1
run: dotnet test src/Lho.Lambda.Tests/Lho.Lambda.Tests.csproj --no-restore
13 changes: 12 additions & 1 deletion .github/actions/validate/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ description: Validate
runs:
using: composite
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"

- name: Build functions
shell: bash
run: swift build -c release
run: |
dotnet build src/Lho.Lambda/Lho.Lambda.csproj
dotnet build src/Lho.Lambda.Authorizer/Lho.Lambda.Authorizer.csproj

- name: Test functions
shell: bash
run: dotnet test src/Lho.Lambda.Tests/Lho.Lambda.Tests.csproj --no-restore
18 changes: 8 additions & 10 deletions .github/workflows/build-prerelease-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,19 @@ jobs:
with:
fetch-depth: 0

- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
bun-version-file: ".bun-version"
dotnet-version: "8.0.x"

- name: Install dependencies
run: bun install --frozen-lockfile
- name: Restore dependencies
run: dotnet restore Lho.Lambda.slnx

- name: Get pre-release version
id: version
run: |
BASE_VERSION=$(jq -r .version package.json)
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
PRERELEASE_VERSION="${BASE_VERSION}-staging.${SHORT_SHA}"
SHORT_SHA="${GITHUB_SHA:0:7}"
PRERELEASE_VERSION="staging.${SHORT_SHA}"
echo "version=${PRERELEASE_VERSION}" >> $GITHUB_OUTPUT
echo "Pre-release version: ${PRERELEASE_VERSION}"

Expand All @@ -57,8 +56,7 @@ jobs:
aws-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
op-service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
env:
VERSION: ${{ steps.version.outputs.version }}
version: ${{ steps.version.outputs.version }}

- name: Summary
run: |
Expand Down
23 changes: 12 additions & 11 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,23 @@ jobs:
- name: Ensure rebased with main
run: ./scripts/ensure-rebased.sh

- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
bun-version-file: ".bun-version"
dotnet-version: "8.0.x"

- name: Install dependencies
run: bun install --frozen-lockfile
- name: Restore dependencies
run: dotnet restore Lho.Lambda.slnx

- name: Get pre-release version
id: version
run: |
BASE_VERSION=$(jq -r .version package.json)
PR_NUMBER=${{ github.event.pull_request.number }}
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
PRERELEASE_VERSION="${BASE_VERSION}-pr.${PR_NUMBER}.${SHORT_SHA}"
PR_NUMBER="${{ github.event.pull_request.number }}"
if [ -z "$PR_NUMBER" ]; then
PR_NUMBER="manual.${GITHUB_RUN_NUMBER}"
fi
SHORT_SHA="${GITHUB_SHA:0:7}"
PRERELEASE_VERSION="staging-pr.${PR_NUMBER}.${SHORT_SHA}"
echo "version=${PRERELEASE_VERSION}" >> $GITHUB_OUTPUT
echo "Pre-release version: ${PRERELEASE_VERSION}"

Expand All @@ -64,8 +66,7 @@ jobs:
aws-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
op-service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
env:
VERSION: ${{ steps.version.outputs.version }}
version: ${{ steps.version.outputs.version }}

- name: Comment on PR
uses: actions/github-script@v7
Expand Down
29 changes: 24 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write

env:
# terraform variables; TODO: move to secretmanager
TF_VAR_env: ${{ github.event.inputs.env == 'staging' && 'staging' || 'live' }}
Expand Down Expand Up @@ -46,11 +50,8 @@ jobs:
- name: Install
uses: ./.github/actions/install

# - name: Validate
# uses: ./.github/actions/validate

# - name: Changelogs
# uses: ./.github/actions/changelog
- name: Validate
uses: ./.github/actions/validate

- name: Deploy
uses: ./.github/actions/deploy
Expand All @@ -59,3 +60,21 @@ jobs:
aws-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
op-service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}

- name: Update changelog
if: ${{ github.event.inputs.env == 'live' && github.ref == 'refs/heads/main' }}
run: |
SHORT_SHA="${GITHUB_SHA:0:7}"
DEPLOY_VERSION="live-${SHORT_SHA}"

bash scripts/update-changelog.sh "${DEPLOY_VERSION}"

if git diff --quiet -- CHANGELOG.md; then
echo "CHANGELOG.md already up to date"
else
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git add CHANGELOG.md
git commit -m "chore(release): publish [skip ci]"
git push
fi
Loading
Loading