From c613c2df868675f5ddc2794c89f0df5febfc06e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lison=20Fernandes?= Date: Fri, 8 Aug 2025 13:38:34 +0100 Subject: [PATCH] [PM-24564] Address GitHub Release creation workflow feedback (#5666) --- .github/actions/log-inputs/action.yml | 20 +++++++ .github/workflows/github-release.yml | 76 +++++++++++++++++++++------ 2 files changed, 80 insertions(+), 16 deletions(-) create mode 100644 .github/actions/log-inputs/action.yml diff --git a/.github/actions/log-inputs/action.yml b/.github/actions/log-inputs/action.yml new file mode 100644 index 0000000000..799fa13871 --- /dev/null +++ b/.github/actions/log-inputs/action.yml @@ -0,0 +1,20 @@ +name: 'Log Inputs to Job Summary' +description: 'Log workflow inputs to the GitHub Actions job summary' + +inputs: + inputs: + description: 'Workflow inputs as JSON' + required: true + +runs: + using: 'composite' + steps: + - name: Log inputs to job summary + shell: bash + run: | + echo "
Job Inputs" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo '```json' >> $GITHUB_STEP_SUMMARY + echo '${{ inputs.inputs }}' >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "
" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml index 8d11eaf831..540cccf7f5 100644 --- a/.github/workflows/github-release.yml +++ b/.github/workflows/github-release.yml @@ -29,6 +29,11 @@ jobs: with: fetch-depth: 0 + - name: Log inputs to job summary + uses: ./.github/actions/log-inputs + with: + inputs: ${{ toJson(inputs) }} + - name: Get branch from workflow run id: get_release_branch env: @@ -45,23 +50,29 @@ jobs: exit 1 fi + echo "🔖 Release branch: $release_branch" + echo "🔖 Workflow name: $workflow_name" echo "release_branch=$release_branch" >> $GITHUB_OUTPUT echo "workflow_name=$workflow_name" >> $GITHUB_OUTPUT case "$workflow_name" in *"Password Manager"* | "Build") - echo "app_name=Password Manager" >> $GITHUB_OUTPUT - echo "app_name_suffix=bwpm" >> $GITHUB_OUTPUT + app_name="Password Manager" + app_name_suffix="bwpm" ;; *"Authenticator"*) - echo "app_name=Authenticator" >> $GITHUB_OUTPUT - echo "app_name_suffix=bwa" >> $GITHUB_OUTPUT + app_name="Authenticator" + app_name_suffix="bwa" ;; *) echo "::error::Unknown workflow name: $workflow_name" exit 1 ;; esac + echo "🔖 App name: $app_name" + echo "🔖 App name suffix: $app_name_suffix" + echo "app_name=$app_name" >> $GITHUB_OUTPUT + echo "app_name_suffix=$app_name_suffix" >> $GITHUB_OUTPUT - name: Get version info from run logs and set release tag name id: get_release_info @@ -99,7 +110,7 @@ jobs: echo "🔖 New tag name: $tag_name" echo "tag_name=$tag_name" >> $GITHUB_OUTPUT - last_release_tag=$(git tag -l --sort=-authordate | grep "$APP_NAME_SUFFIX" | head -n 1) + last_release_tag=$(git tag -l --sort=-authordate | grep "$_APP_NAME_SUFFIX" | head -n 1) echo "🔖 Last release tag: $last_release_tag" echo "last_release_tag=$last_release_tag" >> $GITHUB_OUTPUT @@ -116,6 +127,34 @@ jobs: find $ARTIFACTS_PATH -type f fi + # Files that won't be included in any release + files_to_remove=( + "com.x8bit.bitwarden.aab" + "com.x8bit.bitwarden.aab-sha256.txt" + + "com.x8bit.bitwarden.beta.apk" + "com.x8bit.bitwarden.beta.apk-sha256.txt" + "com.x8bit.bitwarden.beta.aab" + "com.x8bit.bitwarden.beta.aab-sha256.txt" + + "com.x8bit.bitwarden.beta-fdroid.apk" + "com.x8bit.bitwarden.beta-fdroid.apk-sha256.txt" + + "com.x8bit.bitwarden.dev.apk" + "com.x8bit.bitwarden.dev.apk-sha256.txt" + + "com.bitwarden.authenticator.aab" + "authenticator-android-aab-sha256.txt" + ) + + for file in "${files_to_remove[@]}"; do + find $ARTIFACTS_PATH -name "$file" -type f -delete + done + echo "🔖 Removed internal artifacts." + echo "" + echo "🔖 Files to be included in the release:" + find $ARTIFACTS_PATH -type f + - name: Log in to Azure uses: bitwarden/gh-actions/azure-login@main with: @@ -167,34 +206,39 @@ jobs: _TAG_NAME: ${{ steps.get_release_info.outputs.tag_name }} _LAST_RELEASE_TAG: ${{ steps.get_release_info.outputs.last_release_tag }} run: | + is_latest_release=false + if [[ "$_APP_NAME" == "Password Manager" ]]; then + is_latest_release=true + fi + echo "⌛️ Creating release for $_APP_NAME $_VERSION_NAME ($_VERSION_NUMBER) on $_TARGET_COMMIT" release_url=$(gh release create "$_TAG_NAME" \ --title "$_APP_NAME $_VERSION_NAME ($_VERSION_NUMBER)" \ --target "$_TARGET_COMMIT" \ --generate-notes \ --notes-start-tag "$_LAST_RELEASE_TAG" \ + --latest=$is_latest_release \ --draft \ $ARTIFACTS_PATH/*/*) - echo "✅ Release created: $release_url" - - # Get release info for outputs - release_data=$(gh release view "$_TAG_NAME" --json id) - release_id=$(echo "$release_data" | jq -r .id) - - echo "id=$release_id" >> $GITHUB_OUTPUT + # Extract release tag from URL + release_id_from_url=$(echo "$release_url" | sed 's/.*\/tag\///') + echo "release_id_from_url=$release_id_from_url" >> $GITHUB_OUTPUT echo "url=$release_url" >> $GITHUB_OUTPUT + echo "✅ Release created: $release_url" + echo "🔖 Release ID from URL: $release_id_from_url" + - name: Update Release Description id: update_release_description env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} ARTIFACT_RUN_ID: ${{ inputs.artifact-run-id }} _VERSION_NAME: ${{ steps.get_release_info.outputs.version_name }} - _TAG_NAME: ${{ steps.get_release_info.outputs.tag_name }} + _RELEASE_ID: ${{ steps.create_release.outputs.release_id_from_url }} run: | - echo "Getting current release body. Tag: $_TAG_NAME" - current_body=$(gh release view "$_TAG_NAME" --json body --jq .body) + echo "Getting current release body. Release ID: $_RELEASE_ID" + current_body=$(gh release view "$_RELEASE_ID" --json body --jq .body) product_release_notes=$(cat product_release_notes.txt) @@ -205,7 +249,7 @@ jobs: ${current_body} **Builds Source:** https://github.com/${{ github.repository }}/actions/runs/$ARTIFACT_RUN_ID" - new_release_url=$(gh release edit "$_TAG_NAME" --notes "$updated_body") + new_release_url=$(gh release edit "$_RELEASE_ID" --notes "$updated_body") # draft release links change after editing echo "release_url=$new_release_url" >> $GITHUB_OUTPUT