-
Notifications
You must be signed in to change notification settings - Fork 36
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
release: automate regular SAR #758
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5968be8
release: automate regular SAR
v1v c5976f1
Update .github/workflows/release.yml
v1v a76f3ae
Merge branch 'main' into feature/support-sar-automation
v1v e5f8e6c
Update .github/workflows/release.yml
v1v e5f6169
Update .github/workflows/release.yml
v1v 77d6a46
Update .github/workflows/release.yml
v1v 70a2ca8
Apply suggestions from code review
v1v 050ffac
Update .github/workflows/release.yml
v1v ad43b31
fix typo
v1v 3d5bb84
Merge branch 'main' into feature/support-sar-automation
v1v File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,44 @@ 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: | ||
v1v marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# 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: | ||
BUCKET_NAME : "elastic-serverless-forwarder" | ||
AWS_REGION : "eu-central-1" | ||
# elastic-observability-prod | ||
AWS_ACCOUNT_ID: "267093732750" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ needs.release.outputs.tag }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. avoid surprises and use the tag that has been created earlier |
||
|
||
- 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 \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It runs the same command in #279 (comment) |
||
elastic-serverless-forwarder \ | ||
${{ needs.release.outputs.version }} \ | ||
${{ env.BUCKET_NAME }} \ | ||
${{ env.AWS_ACCOUNT_ID }} \ | ||
${{ env.AWS_REGION }} \ | ||
"Elastic" | ||
kaiyan-sheng marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run this job only if there is a new tag and in a separate job so we can see if things work as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this.
We also only upload dependencies to the bucket when this workflow succeeds:
elastic-serverless-forwarder/.github/workflows/upload-dependencies.yml
Lines 11 to 15 in 70a2ca8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, there is a corner case in
elastic-serverless-forwarder/.github/workflows/upload-dependencies.yml
Line 32 in 70a2ca8
2 or more
commits happened in a row inshare/version.py
whileupload-dependencies.yml
has not been executed yet.We can do a follow-up and see if that's a genuine reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you. There is also another problem: if a commit happens and the tag is not updated (so no version upgrade). I don't see why a commit would not cause a version upgrade, but we do not check that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!