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

github-action: provenance generation #2315

Merged
merged 21 commits into from
Jun 6, 2024
Merged

github-action: provenance generation #2315

merged 21 commits into from
Jun 6, 2024

Conversation

v1v
Copy link
Member

@v1v v1v commented Mar 25, 2024

What does this pull request do?

Use https://github.com/github-early-access/generate-build-provenance to create build attestations

Test

Using a test feature branch and skip upload artifacts or slack notifications:

diff --git a/.github/workflows/release-main.yml b/.github/workflows/release-main.yml
index d0ef4f1a..b8ec9e29 100644
--- a/.github/workflows/release-main.yml
+++ b/.github/workflows/release-main.yml
@@ -2,7 +2,7 @@ name: release-main
 
 on:
   push:
-    branches: [ "main" ]
+    branches: [ "main", "test/provenance" ]
 
 permissions:
   attestations: write
@@ -36,12 +36,14 @@ jobs:
 
     # Github packages requires authentication, this is likely going away in the future so for now we publish to feedz.io
     - name: publish canary packages to feedz.io
+      if: startsWith(github.ref, 'refs/tags')
       run: dotnet nuget push 'build/output/_packages/*.nupkg' -k ${{ secrets.FEEDZ_IO_API_KEY }} -s ${{ secrets.FEEDZ_IO_API_URL }} --skip-duplicate --no-symbols
       
     - name: publish canary packages github package repository
+      if: startsWith(github.ref, 'refs/tags')
       run: dotnet nuget push 'build/output/_packages/*.nupkg' -k ${{secrets.GITHUB_TOKEN}} -s https://nuget.pkg.github.com/elastic/index.json --skip-duplicate --no-symbols
     
-    - if: ${{ failure() }}
+    - if: ${{ failure() && startsWith(github.ref, 'refs/tags') }}
       uses: elastic/oblt-actions/slack/[email protected]
       with:
         bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 4933a4c4..576d9215 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -3,6 +3,8 @@ name: release
 on:
   release:
     types: [published]
+  push:
+    branches: [ "test/provenance" ]
 
 permissions:
   contents: write
@@ -39,6 +41,7 @@ jobs:
       run: ./build.sh pack
 
     - name: Release to Nuget
+      if: startsWith(github.ref, 'refs/tags')
       run: .ci/linux/deploy.sh ${{ secrets.NUGET_API_KEY }} ${{ secrets.NUGET_API_URL }}
 
     - name: Set up Docker Buildx
@@ -97,13 +100,14 @@ jobs:
         subject-path: "${{ github.workspace }}/${{ env.PREFIX_APM_PROFILER }}${{ steps.bootstrap.outputs.agent-version }}${{ env.SUFFIX_APM_PROFILER }}"
 
     - name: Attach Profiler And Startup Hooks
+      if: startsWith(github.ref, 'refs/tags')
       continue-on-error: true #continue for now until we see it working in action
       env:
         GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
       run: |
         gh release upload ${{ github.ref_name }} "${{ env.PREFIX_APM_AGENT }}${{ steps.bootstrap.outputs.agent-version }}${{ env.SUFFIX_APM_AGENT }}" "${{ env.PREFIX_APM_PROFILER }}${{ steps.bootstrap.outputs.agent-version }}${{ env.SUFFIX_APM_PROFILER }}"
 
-    - if: ${{ success() }}
+    - if: ${{ success() && startsWith(github.ref, 'refs/tags') }}
       uses: elastic/oblt-actions/slack/[email protected]
       with:
         bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
@@ -113,7 +117,7 @@ jobs:
           Build: (<${{ env.JOB_URL }}|here>)
           Release URL: (<https://github.com/elastic/apm-agent-dotnet/releases/tag/${{ github.ref_name }}|${{ github.ref_name }}>)
 
-    - if: ${{ failure() }}
+    - if: ${{ failure() && startsWith(github.ref, 'refs/tags') }}
       uses: elastic/oblt-actions/slack/[email protected]
       with:
         bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
@@ -152,6 +156,7 @@ jobs:
           subject-path: "${{ github.workspace }}/${{ env.PREFIX_ZIP_FILE }}${{ steps.bootstrap.outputs.agent-version }}${{ env.SUFFIX_ZIP_FILE }}"
 
       - name: Attach Profiler
+        if: startsWith(github.ref, 'refs/tags')
         env:
           GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         continue-on-error: true #continue for now until we see it working in action
@@ -161,6 +166,7 @@ jobs:
   post-release:
     needs: [ 'release-windows']
     runs-on: ubuntu-latest
+    if: startsWith(github.ref, 'refs/tags')
     env:
       GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
       GIT_TAG: v${{ needs.release-windows.outputs.agent-version }}

.github/workflows/release.yml Outdated Show resolved Hide resolved
@v1v v1v self-assigned this Apr 22, 2024
@v1v v1v requested a review from a team April 22, 2024 15:50
@v1v v1v marked this pull request as ready for review April 22, 2024 15:50
@v1v v1v requested a review from a team April 22, 2024 15:50
reakaleek
reakaleek previously approved these changes Apr 22, 2024
@v1v v1v changed the title github-action: provenance generation (initial attempt) github-action: provenance generation Apr 26, 2024
.github/workflows/release.yml Outdated Show resolved Hide resolved
@v1v
Copy link
Member Author

v1v commented Apr 29, 2024

run docs-build

reakaleek
reakaleek previously approved these changes May 6, 2024
Mpdreamz
Mpdreamz previously approved these changes May 22, 2024
@v1v v1v dismissed stale reviews from Mpdreamz and reakaleek via e105c8b May 28, 2024 19:18
Mpdreamz
Mpdreamz previously approved these changes May 28, 2024
@v1v
Copy link
Member Author

v1v commented May 29, 2024

I'll test this in isolation to validate things work as expected after the merge I ran recently

.github/workflows/release.yml Outdated Show resolved Hide resolved
.github/workflows/release.yml Outdated Show resolved Hide resolved
.github/workflows/release.yml Outdated Show resolved Hide resolved
.github/workflows/release.yml Outdated Show resolved Hide resolved
@v1v v1v requested a review from reakaleek June 6, 2024 11:12
@v1v
Copy link
Member Author

v1v commented Jun 6, 2024

All good now, it took me a while to verify things worked nice/smoothly... so I feel we are now in a good position to merge this PR.

Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm merge at will :)

@v1v v1v merged commit b12e219 into main Jun 6, 2024
14 of 15 checks passed
@v1v v1v deleted the feature/provenance branch June 6, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants