Skip to content

Commit

Permalink
release: Add releases flows (#1070)
Browse files Browse the repository at this point in the history
  • Loading branch information
flemzord authored Dec 21, 2023
1 parent f7948d2 commit 4ba6f67
Show file tree
Hide file tree
Showing 1,309 changed files with 8,301 additions and 20,832 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/release-stack.yml

This file was deleted.

65 changes: 0 additions & 65 deletions .github/workflows/release.yml

This file was deleted.

97 changes: 97 additions & 0 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Release
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write

jobs:
Dirty:
runs-on: "formance-runner"
steps:
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- name: Setup Env
uses: ./.github/actions/env
- run: >
earthly
--allow-privileged
--secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY
--secret GITHUB_TOKEN=$GITHUB_TOKEN
${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
+pre-commit
env:
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v40
with:
since_last_remote_commit: true
- name: Run step if test file(s) change
if: steps.changed-files.outputs.all_changed_files == 'true'
run: |
echo "One or more test file(s) has changed."
echo "List all the files that have changed: ${{ steps.changed-files.outputs.all_changed_files }}"
exit 1
Extract:
name: Extract
runs-on: "ubuntu-latest"
outputs:
components: ${{ steps.extract.outputs.components }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Extract service name
id: extract
run: echo "components=$(node .github/actions/find-directory/index.js)" >> $GITHUB_OUTPUT

GoReleaser:
runs-on: "ubuntu-latest"
if: contains(github.event.pull_request.labels.*.name, 'build-images') || github.ref == 'refs/heads/main'
needs:
- Extract
- Dirty
strategy:
matrix:
components: ${{ fromJson(needs.Extract.outputs.components) }}
steps:
- uses: earthly/actions-setup@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: "latest"
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- name: Setup Env
uses: ./.github/actions/env
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: "NumaryBot"
password: ${{ secrets.NUMARY_GITHUB_TOKEN }}
- run: >
earthly
--no-output
--allow-privileged
--secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY
--secret SEGMENT_WRITE_KEY=$SEGMENT_WRITE_KEY
--secret GITHUB_TOKEN=$GITHUB_TOKEN
--secret FURY_TOKEN=$FURY_TOKEN
--secret GORELEASER_KEY=$GORELEASER_KEY
${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
+goreleaser --type=${{ matrix.components.type }} --components=${{ matrix.components.component }} --mode=ci
env:
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_OSS }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ worktrees

# Earthly
.tmp-earthly-out

# Ignore SDKS
sdks
.DS_Store
openapi/node_modules
releases/sdks


.kubeconfig
41 changes: 16 additions & 25 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ speakeasy:
SAVE ARTIFACT speakeasy

build-final-spec:
ARG version=INTERNAL
FROM core+base-image
RUN apk update && apk add yarn nodejs npm jq
WORKDIR /src/libs/clients
COPY libs/clients/package.* .
WORKDIR /src/releases
COPY releases/package.* .
RUN npm install
WORKDIR /src/components
FOR c IN payments ledger
Expand All @@ -34,30 +35,21 @@ build-final-spec:
COPY (./ee/$c+openapi/openapi.yaml) /src/ee/$c/
END

WORKDIR /src/libs/clients
COPY libs/clients/base.yaml .
COPY libs/clients/openapi-overlay.json .
COPY libs/clients/openapi-merge.json .
WORKDIR /src/releases
COPY releases/base.yaml .
COPY releases/openapi-overlay.json .
COPY releases/openapi-merge.json .
RUN mkdir ./build
RUN npm run build
RUN jq -s '.[0] * .[1]' build/generate.json openapi-overlay.json > build/final.json
RUN sed -i 's/SDK_VERSION/INTERNAL/g' build/final.json
SAVE ARTIFACT build/final.json AS LOCAL libs/clients/build/generate.json

build-sdk:
BUILD --pass-args +build-final-spec # Force output of the final spec
FROM core+base-image
WORKDIR /src
RUN apk update && apk add yq
COPY (+speakeasy/speakeasy) /bin/speakeasy
COPY (+build-final-spec/final.json) final-spec.json
COPY --dir libs/clients/go ./sdks/go
IF [ "SPEAKEASY_API_KEY" != "" ]
RUN --secret SPEAKEASY_API_KEY speakeasy generate sdk -s ./final-spec.json -o ./sdks/go -l go
RUN jq -s '.[0] * .[1]' build/generate.json openapi-overlay.json > build/latest.json
IF [ "$version" = "INTERNAL" ]
RUN sed -i 's/SDK_VERSION/INTERNAL/g' build/latest.json
SAVE ARTIFACT build/latest.json AS LOCAL releases/build/latest.json
ELSE
RUN sed -i 's/SDK_VERSION/'$version'/g' build/latest.json
SAVE ARTIFACT build/latest.json AS LOCAL releases/build/$version.json
END
RUN rm -rf ./libs/clients/go
SAVE ARTIFACT sdks/go AS LOCAL ./libs/clients/go
SAVE ARTIFACT sdks/go
SAVE ARTIFACT build/latest.json

openapi:
FROM core+base-image
Expand All @@ -77,7 +69,6 @@ goreleaser:
ARG --required components
ARG --required type
COPY . /src
COPY (+build-sdk/go --LANG=go) /src/libs/clients/go
WORKDIR /src/$type/$components
ARG mode=local
LET buildArgs = --clean
Expand Down Expand Up @@ -149,7 +140,7 @@ tests-integration:

pre-commit: # Generate the final spec and run all the pre-commit hooks
LOCALLY
BUILD --pass-args +build-sdk
BUILD --pass-args ./releases+sdk-generate
FOR component IN $(cd ./components && ls -d */)
BUILD --pass-args ./components/${component}+pre-commit
END
Expand Down
3 changes: 2 additions & 1 deletion components/fctl/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ VERSION --pass-args --arg-scope-and-set 0.7
ARG core=github.com/formancehq/earthly:v0.6.0
IMPORT $core AS core
IMPORT ../.. AS stack
IMPORT ../../releases AS releases
IMPORT .. AS components

FROM core+base-image
Expand All @@ -18,7 +19,7 @@ tests:

sources:
WORKDIR src
COPY --pass-args (stack+build-sdk/go) libs/clients/go
COPY --pass-args (releases+sdk-generate/go) /src/releases/sdks/go
DO stack+INCLUDE_GO_LIBS --LOCATION libs/go-libs
WORKDIR /src/components/fctl
COPY go.* .
Expand Down
2 changes: 1 addition & 1 deletion components/fctl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ replace github.com/formancehq/fctl/membershipclient => ./membershipclient

replace github.com/spf13/cobra v1.6.1 => github.com/formancehq/cobra v0.0.0-20221112160629-60a6d6d55ef9

replace github.com/formancehq/formance-sdk-go => ../../libs/clients/go
replace github.com/formancehq/formance-sdk-go => ../../releases/sdks/go
2 changes: 1 addition & 1 deletion components/ledger/.goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project_name: ledger
monorepo:
tag_prefix: components/ledger/
tag_prefix: v
dir: ./

includes:
Expand Down
2 changes: 1 addition & 1 deletion components/operator/.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ includes:
path: ./../../.goreleaser.default.yaml

monorepo:
tag_prefix: components/operator/
tag_prefix: v
dir: ./

builds:
Expand Down
2 changes: 1 addition & 1 deletion components/payments/.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ includes:
- from_file:
path: ./../../.goreleaser.default.yaml
monorepo:
tag_prefix: components/payments/
tag_prefix: v
dir: ./

builds:
Expand Down
3 changes: 2 additions & 1 deletion components/payments/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ VERSION --pass-args --arg-scope-and-set 0.7
ARG core=github.com/formancehq/earthly:v0.6.0
IMPORT $core AS core
IMPORT ../.. AS stack
IMPORT ../../releases AS releases
IMPORT .. AS components

FROM core+base-image

sources:
WORKDIR src
DO stack+INCLUDE_GO_LIBS --LOCATION libs/go-libs
COPY --pass-args (stack+build-sdk/go) libs/clients/go
COPY --pass-args (releases+sdk-generate/go) /src/releases/sdks/go
WORKDIR /src/components/payments
COPY go.* .
COPY --dir pkg cmd internal .
Expand Down
2 changes: 1 addition & 1 deletion ee/agent/.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ includes:
- from_file:
path: ./../../.goreleaser.default.yaml
monorepo:
tag_prefix: ee/agent/
tag_prefix: v
dir: ./

builds:
Expand Down
2 changes: 1 addition & 1 deletion ee/auth/.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ includes:
- from_file:
path: ./../../.goreleaser.default.yaml
monorepo:
tag_prefix: ee/auth/
tag_prefix: v
dir: ./

builds:
Expand Down
2 changes: 1 addition & 1 deletion ee/gateway/.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ includes:
- from_file:
path: ./../../.goreleaser.default.yaml
monorepo:
tag_prefix: ee/gateway/
tag_prefix: v
dir: ./

builds:
Expand Down
2 changes: 1 addition & 1 deletion ee/orchestration/.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ includes:
- from_file:
path: ./../../.goreleaser.default.yaml
monorepo:
tag_prefix: ee/orchestration/
tag_prefix: v
dir: ./

builds:
Expand Down
3 changes: 2 additions & 1 deletion ee/orchestration/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ VERSION --pass-args --arg-scope-and-set 0.7
ARG core=github.com/formancehq/earthly:v0.6.0
IMPORT $core AS core
IMPORT ../.. AS stack
IMPORT ../../releases AS releases
IMPORT .. AS ee

FROM core+base-image

sources:
WORKDIR src
DO stack+INCLUDE_GO_LIBS --LOCATION libs/go-libs
COPY --pass-args (stack+build-sdk/go) libs/clients/go
COPY --pass-args (releases+sdk-generate/go) /src/releases/sdks/go
WORKDIR /src/ee/orchestration
COPY go.* .
COPY --dir pkg cmd internal .
Expand Down
Loading

0 comments on commit 4ba6f67

Please sign in to comment.