From 5968be8e6aa50d758e414782acb50606dc98bfa5 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 6 Aug 2024 17:27:23 +0200 Subject: [PATCH 1/8] release: automate regular SAR --- .github/workflows/release.yml | 48 ++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ced43106..bcc72864 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 + outputs: + version: ${{ steps.version.outputs.version }} + enabled: ${{ steps.version.outputs.enabled }} + tag: ${{ steps.version.outputs.tag }} steps: - uses: actions/checkout@v4 @@ -30,6 +34,7 @@ jobs: echo "::notice::ESF version is $VERSION." - name: Check if version increased + id: version shell: bash run: | git fetch --tags @@ -61,6 +66,10 @@ jobs: echo "::notice::Current version is ${{ env.VERSION }}." echo "::notice::The result for creating tag is $CREATE_TAG." + echo "version=${{ env.VERSION }}" >> "$GITHUB_OUTPUT" + echo "enabled=${CREATE_TAG}"" >> "$GITHUB_OUTPUT" + echo "tag=lambda-v${{ env.VERSION }}" >> "$GITHUB_OUTPUT" + - name: Create tag if: env.CREATE_TAG == 'true' # run only in case CREATE_TAG is true uses: actions/github-script@v7 @@ -69,6 +78,43 @@ jobs: github.rest.git.createRef({ owner: context.repo.owner, repo: context.repo.repo, - ref: 'refs/tags/lambda-v' + "${{ env.VERSION }}", + ref: 'refs/tags/' + "${{ steps.version.outputs.tag }}", sha: context.sha }) + + regular-sar: + if: ${{ needs.release.outputs.enabled == 'true' }} + runs-on: ubuntu-latest + needs: release + permissions: + id-token: write + contents: read + env: + BUCKET_NAME : "esf-dependencies" + AWS_REGION : "eu-central-1" + # elastic-observability-prod + AWS_ACCOUNT_ID: "267093732750" + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.release.outputs.tag }} + + - uses: elastic/oblt-actions/aws/auth@v1 + with: + aws-account-id: "${{ env.AWS_ACCOUNT_ID}}" + aws-region: "${{ env.AWS_REGION }}" + + - uses: aws-actions/setup-sam@2360ef6d90015369947b45b496193ab9976a9b04 # v2 + with: + use-installer: true + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and package + run: | + .internal/aws/scripts/dist.sh \ + elastic-serverless-forwarder \ + ${{ needs.release.outputs.version }} \ + elastic-serverless-forwarder-artifacts \ + ${{ env.AWS_ACCOUNT_ID }} \ + ${{ env.AWS_REGION }} \ + "GitHub Bot" From c5976f1ed2cb50285dc375136758b30d00ee4b2e Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 27 Aug 2024 17:45:31 +0200 Subject: [PATCH 2/8] Update .github/workflows/release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bcc72864..33fbff47 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -114,7 +114,7 @@ jobs: .internal/aws/scripts/dist.sh \ elastic-serverless-forwarder \ ${{ needs.release.outputs.version }} \ - elastic-serverless-forwarder-artifacts \ + elastic-serverless-forwarder \ ${{ env.AWS_ACCOUNT_ID }} \ ${{ env.AWS_REGION }} \ "GitHub Bot" From e5f8e6c3a1a16af4e0242b2a84e433cac5c023bc Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 27 Aug 2024 17:48:19 +0200 Subject: [PATCH 3/8] Update .github/workflows/release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 33fbff47..10450b68 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -117,4 +117,4 @@ jobs: elastic-serverless-forwarder \ ${{ env.AWS_ACCOUNT_ID }} \ ${{ env.AWS_REGION }} \ - "GitHub Bot" + "Elastic" From e5f616947eb369282c5a0bd5bfed459416c62218 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 27 Aug 2024 17:52:06 +0200 Subject: [PATCH 4/8] Update .github/workflows/release.yml --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 10450b68..fab25b0a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -87,6 +87,7 @@ jobs: runs-on: ubuntu-latest needs: release permissions: + # See https://github.com/elastic/oblt-infra/tree/main/conf/resources/repos/elastic-serverless-forwarder/01-release.tf id-token: write contents: read env: From 77d6a469d277c3854618a00c2a102567c57ce06a Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 27 Aug 2024 18:12:56 +0200 Subject: [PATCH 5/8] Update .github/workflows/release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fab25b0a..e03cda8b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -87,7 +87,7 @@ jobs: runs-on: ubuntu-latest needs: release permissions: - # See https://github.com/elastic/oblt-infra/tree/main/conf/resources/repos/elastic-serverless-forwarder/01-release.tf + # The OIDC permissions can be found at https://github.com/elastic/oblt-infra/tree/main/conf/resources/repos/elastic-serverless-forwarder id-token: write contents: read env: From 70a2ca89087f664d3d2a14699b6aa0856a620f03 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 27 Aug 2024 18:14:33 +0200 Subject: [PATCH 6/8] Apply suggestions from code review --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e03cda8b..29ffde94 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -91,7 +91,7 @@ jobs: id-token: write contents: read env: - BUCKET_NAME : "esf-dependencies" + BUCKET_NAME : "elastic-serverless-forwarder" AWS_REGION : "eu-central-1" # elastic-observability-prod AWS_ACCOUNT_ID: "267093732750" @@ -115,7 +115,7 @@ jobs: .internal/aws/scripts/dist.sh \ elastic-serverless-forwarder \ ${{ needs.release.outputs.version }} \ - elastic-serverless-forwarder \ + ${{ env. BUCKET_NAME }} \ ${{ env.AWS_ACCOUNT_ID }} \ ${{ env.AWS_REGION }} \ "Elastic" From 050ffac87aca5a81d8f6d1a5e3df2550bffaeaba Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 28 Aug 2024 09:05:19 +0200 Subject: [PATCH 7/8] Update .github/workflows/release.yml Co-authored-by: Jan Calanog --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 29ffde94..1fb55e4c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -102,7 +102,7 @@ jobs: - uses: elastic/oblt-actions/aws/auth@v1 with: - aws-account-id: "${{ env.AWS_ACCOUNT_ID}}" + aws-account-id: "${{ env.AWS_ACCOUNT_ID }}" aws-region: "${{ env.AWS_REGION }}" - uses: aws-actions/setup-sam@2360ef6d90015369947b45b496193ab9976a9b04 # v2 From ad43b313cf38a53555e26dffdfb7c83aa1328df7 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 11 Sep 2024 09:15:52 +0200 Subject: [PATCH 8/8] fix typo --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1fb55e4c..daf11d73 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -115,7 +115,7 @@ jobs: .internal/aws/scripts/dist.sh \ elastic-serverless-forwarder \ ${{ needs.release.outputs.version }} \ - ${{ env. BUCKET_NAME }} \ + ${{ env.BUCKET_NAME }} \ ${{ env.AWS_ACCOUNT_ID }} \ ${{ env.AWS_REGION }} \ "Elastic"