3232 MAIN_BRANCH : main
3333 RELEASE_BRANCH : release
3434 PROPOSAL_BRANCH_PREFIX : release-proposal
35+ GIT_USER_NAME : " dd-octo-sts[bot]"
36+ GIT_USER_EMAIL : " 200755185+dd-octo-sts[bot]@users.noreply.github.com"
3537
3638jobs :
3739 check-proposal-ongoing :
@@ -53,29 +55,75 @@ jobs:
5355 fi
5456 echo "No release proposal is ongoing."
5557
58+ check-membership :
59+ permissions :
60+ id-token : write # Enable OIDC
61+ runs-on : ubuntu-latest
62+ needs : check-proposal-ongoing
63+ steps :
64+ - uses : DataDog/dd-octo-sts-action@08f2144903ced3254a3dafec2592563409ba2aa0 # v1.0.1
65+ id : octo-sts
66+ with :
67+ scope : DataDog/libdatadog # target repository
68+ policy : self.read.members # trust policy in target repo, without the .sts.yaml extension
69+
70+ - name : Check if user is in the team allowed to make crate releases
71+ id : check
72+ uses : TheModdingInquisition/actions-team-membership@057d91bb80f2976a1bc6dfab5b4ae1da9aebbd89 # v1.0.1
73+ with :
74+ team : ' apm-common-components-core'
75+ organization : ' Datadog'
76+ token : ${{ steps.octo-sts.outputs.token }} # Needs 'read:org' scope
77+ exit : false
78+
79+ - name : Check output
80+ run : |
81+ permitted=${{ steps.check.outputs.permitted }}
82+ if [[ "$permitted" != "true" ]]; then
83+ echo "User is not part of apm-common-components-core"
84+ exit 1
85+ fi
86+
5687 update-release-branch :
5788 permissions :
5889 id-token : write # Enable OIDC
5990 contents : write
6091 runs-on : ubuntu-latest
61- needs : check-proposal-ongoing
92+ needs : check-membership
6293 steps :
94+ - uses : DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
95+ id : octo-sts
96+ with :
97+ scope : DataDog/libdatadog
98+ policy : self.write.pr
99+
63100 - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
64101 with :
102+ token : ${{ steps.octo-sts.outputs.token }}
65103 fetch-depth : 0
66104 fetch-tags : true
105+
106+ - name : Configure Git identity for dd-octo-sts GitHub App
107+ env :
108+ GH_TOKEN : ${{ steps.octo-sts.outputs.token }}
109+ run : |
110+
111+ git config --global user.name "$GIT_USER_NAME"
112+ git config --global user.email "$GIT_USER_EMAIL"
113+
67114 - name : Merge the main branch into the release branch
68115 run : |
69116 git fetch origin "${{ env.RELEASE_BRANCH }}" --tags
70117 git checkout "${{ env.RELEASE_BRANCH }}"
71- # only fast-forward the merge
72- if ! git merge --ff-only origin/"${{ env.MAIN_BRANCH }}"; then
73- echo "Error: Cannot fast-forward merge ${{ env.MAIN_BRANCH }} into ${{ env.RELEASE_BRANCH }}" >&2
74- echo "The branches have diverged." >&2
118+
119+ if ! git merge origin/"${{ env.MAIN_BRANCH }}"; then
120+ echo "Error: Cannot merge ${{ env.MAIN_BRANCH }} into ${{ env.RELEASE_BRANCH }}" >&2
121+ echo "There are merge conflicts or the branches have diverged." >&2
75122 echo "If you have recently launched another release, it is possible that ${{ env.MAIN_BRANCH }} branch is not yet updated with the ${{ env.RELEASE_BRANCH }} changes." >&2
76123 echo "Please try again later." >&2
77124 exit 1
78125 fi
126+
79127 git push origin "${{ env.RELEASE_BRANCH }}" --tags
80128
81129 cargo-release :
@@ -85,12 +133,12 @@ jobs:
85133 contents : write
86134 needs : update-release-branch
87135 runs-on : ubuntu-latest
88- # TODO: uncomment this when we have a way to test this workflow
89- # if: ${{ github.repository_owner == 'datadog' }}
90136 steps :
91137 - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
92138 with :
93- fetch-depth : 0 # Need full history for git tags
139+ ref : ${{ env.RELEASE_BRANCH }}
140+ fetch-depth : 0
141+ fetch-tags : true
94142 - uses : Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
95143 with :
96144 cache-targets : true
@@ -117,8 +165,8 @@ jobs:
117165
118166 - name : Configure Git for signing
119167 run : |
120- git config --global user.name "github-actions[bot] "
121- git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com "
168+ git config --global user.name "${{ env.GIT_USER_NAME }} "
169+ git config --global user.email "${{ env.GIT_USER_EMAIL }} "
122170
123171 - name : Get publication order for crate and dependencies
124172 run : |
@@ -140,6 +188,14 @@ jobs:
140188 - name : Create a branch for the release proposal
141189 id : proposal-branch
142190 run : |
191+ git status
192+
193+ IS_SHALLOW=$(git rev-parse --is-shallow-repository)
194+ if [ "$IS_SHALLOW" = "true" ]; then
195+ echo "Repository is shallow"
196+ git pull --unshallow
197+ fi
198+
143199 git checkout "${{ env.RELEASE_BRANCH }}"
144200 TIMESTAMP=$(date +%Y%m%d-%H%M%S)
145201 BRANCH_NAME="${{ env.PROPOSAL_BRANCH_PREFIX }}/${{ inputs.crate }}/$TIMESTAMP"
@@ -334,7 +390,6 @@ jobs:
334390 "",
335391 (if $api_info.version then "**Next version:** `\($api_info.version)`\n" else null end),
336392 "**Semver bump:** `\($api_info.level)`",
337- "",
338393 (if $api_info.tag then "**Tag:** `\($api_info.tag)`\n" else null end),
339394 (if $api_info.initial_release == "true" then
340395 "**Warning:** this is an initial release. Please verify that the version and commits included are correct.\n"
0 commit comments