-
Notifications
You must be signed in to change notification settings - Fork 1k
Agalles/create deploy workflow trigger #7093
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
Open
AmyLGalles
wants to merge
4
commits into
main
Choose a base branch
from
agalles/create-deploy-workflow-trigger
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+11
β274
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,283 +12,20 @@ on: | |||||||||
| required: true | ||||||||||
| type: string | ||||||||||
|
|
||||||||||
| env: | ||||||||||
| ARTIFACTS_PATH: artifacts | ||||||||||
|
|
||||||||||
| jobs: | ||||||||||
| create-release: | ||||||||||
| name: Create GitHub Release | ||||||||||
| deploy: | ||||||||||
| name: Trigger publish via deploy repo | ||||||||||
| runs-on: ubuntu-24.04 | ||||||||||
| permissions: | ||||||||||
| contents: write | ||||||||||
| id-token: write | ||||||||||
|
|
||||||||||
| steps: | ||||||||||
| - name: Check out repository | ||||||||||
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||||||||||
| with: | ||||||||||
| fetch-depth: 0 | ||||||||||
| persist-credentials: true | ||||||||||
|
|
||||||||||
| - 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: | ||||||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||
| ARTIFACT_RUN_ID: ${{ inputs.artifact-run-id }} | ||||||||||
| run: | | ||||||||||
| workflow_data=$(gh run view "$ARTIFACT_RUN_ID" --json headBranch,workflowName) | ||||||||||
| release_branch=$(echo "$workflow_data" | jq -r .headBranch) | ||||||||||
| workflow_name=$(echo "$workflow_data" | jq -r .workflowName) | ||||||||||
|
|
||||||||||
| # branch protection check | ||||||||||
| if [[ "$release_branch" != "main" && ! "$release_branch" =~ ^release/ ]]; then | ||||||||||
| echo "::error::Branch '$release_branch' is not 'main' or a release branch starting with 'release/'. Releases must be created from protected branches." | ||||||||||
| 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") | ||||||||||
| app_name="Password Manager" | ||||||||||
| app_name_suffix="bwpm" | ||||||||||
| ;; | ||||||||||
| *"Authenticator"*) | ||||||||||
| 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 | ||||||||||
| env: | ||||||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||
| ARTIFACT_RUN_ID: ${{ inputs.artifact-run-id }} | ||||||||||
| _APP_NAME_SUFFIX: ${{ steps.get_release_branch.outputs.app_name_suffix }} | ||||||||||
| run: | | ||||||||||
| workflow_log=$(gh run view "$ARTIFACT_RUN_ID" --log) | ||||||||||
|
|
||||||||||
| version_number_with_trailing_dot=$(grep -m 1 "Setting version code to" <<< "$workflow_log" | sed 's/.*Setting version code to //') | ||||||||||
| version_number=${version_number_with_trailing_dot%.} # remove trailing dot | ||||||||||
|
|
||||||||||
| version_name_with_trailing_dot=$(grep -m 1 "Setting version name to" <<< "$workflow_log" | sed 's/.*Setting version name to //') | ||||||||||
| version_name=${version_name_with_trailing_dot%.} # remove trailing dot | ||||||||||
|
|
||||||||||
| if [[ -z "$version_name" ]]; then | ||||||||||
| echo "::warning::Version name not found. Using default value - 0.0.0" | ||||||||||
| version_name="0.0.0" | ||||||||||
| else | ||||||||||
| echo "β Found version name: $version_name" | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| if [[ -z "$version_number" ]]; then | ||||||||||
| echo "::warning::Version number not found. Using default value - 0" | ||||||||||
| version_number="0" | ||||||||||
| else | ||||||||||
| echo "β Found version number: $version_number" | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| echo "version_number=$version_number" >> "$GITHUB_OUTPUT" | ||||||||||
| echo "version_name=$version_name" >> "$GITHUB_OUTPUT" | ||||||||||
|
|
||||||||||
| tag_name="v$version_name-$_APP_NAME_SUFFIX" # e.g. v2025.6.0-bwpm | ||||||||||
| 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) | ||||||||||
| echo "π Last release tag: $last_release_tag" | ||||||||||
| echo "last_release_tag=$last_release_tag" >> "$GITHUB_OUTPUT" | ||||||||||
|
|
||||||||||
| - name: Download artifacts | ||||||||||
| env: | ||||||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||
| ARTIFACT_RUN_ID: ${{ inputs.artifact-run-id }} | ||||||||||
| run: | | ||||||||||
| gh run download "$ARTIFACT_RUN_ID" -D "$ARTIFACTS_PATH" | ||||||||||
| file_count=$(find "$ARTIFACTS_PATH" -type f | wc -l) | ||||||||||
| echo "Downloaded $file_count file(s)." | ||||||||||
| if [ "$file_count" -gt 0 ]; then | ||||||||||
| echo "Downloaded files:" | ||||||||||
| 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 | ||||||||||
| - name: Trigger publish | ||||||||||
| uses: bitwarden/gh-actions/trigger-actions@main | ||||||||||
| with: | ||||||||||
| subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||||||||||
| tenant_id: ${{ secrets.AZURE_TENANT_ID }} | ||||||||||
| client_id: ${{ secrets.AZURE_CLIENT_ID }} | ||||||||||
|
|
||||||||||
| - name: Get Azure Key Vault secrets | ||||||||||
| id: get-kv-secrets | ||||||||||
| uses: bitwarden/gh-actions/get-keyvault-secrets@main | ||||||||||
| with: | ||||||||||
| keyvault: gh-android | ||||||||||
| secrets: "JIRA-API-EMAIL,JIRA-API-TOKEN,JIRA-CLOUD-ID" | ||||||||||
|
|
||||||||||
| - name: Log out from Azure | ||||||||||
| uses: bitwarden/gh-actions/azure-logout@main | ||||||||||
|
|
||||||||||
| - name: Get product release notes | ||||||||||
| id: get_release_notes | ||||||||||
| env: | ||||||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||
| ARTIFACT_RUN_ID: ${{ inputs.artifact-run-id }} | ||||||||||
| _VERSION_NAME: ${{ steps.get_release_info.outputs.version_name }} | ||||||||||
| _RELEASE_TICKET_ID: ${{ inputs.release-ticket-id }} | ||||||||||
| _JIRA_CLOUD_ID: ${{ steps.get-kv-secrets.outputs.JIRA-CLOUD-ID }} | ||||||||||
| _JIRA_API_EMAIL: ${{ steps.get-kv-secrets.outputs.JIRA-API-EMAIL }} | ||||||||||
| _JIRA_API_TOKEN: ${{ steps.get-kv-secrets.outputs.JIRA-API-TOKEN }} | ||||||||||
| run: | | ||||||||||
| echo "Getting product release notes..." | ||||||||||
| # capture output and exit code so this step continues even if we can't retrieve release notes. | ||||||||||
| script_exit_code=0 | ||||||||||
| product_release_notes=$(python3 .github/scripts/jira-get-release-notes/jira_release_notes.py "$_RELEASE_TICKET_ID" "$_JIRA_CLOUD_ID" "$_JIRA_API_EMAIL" "$_JIRA_API_TOKEN") || script_exit_code=$? | ||||||||||
| echo "--------------------------------" | ||||||||||
|
|
||||||||||
| if [[ $script_exit_code -ne 0 || -z "$product_release_notes" ]]; then | ||||||||||
| echo "Script Output: $product_release_notes" | ||||||||||
| echo "::warning::Failed to fetch release notes from Jira. Check script logs for more details." | ||||||||||
| product_release_notes="<insert product release notes here>" | ||||||||||
| else | ||||||||||
| echo "β Product release notes:" | ||||||||||
| echo "$product_release_notes" | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| echo "$product_release_notes" > product_release_notes.txt | ||||||||||
|
|
||||||||||
| - name: Create Release | ||||||||||
| id: create_release | ||||||||||
| env: | ||||||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||
| _APP_NAME: ${{ steps.get_release_branch.outputs.app_name }} | ||||||||||
| _VERSION_NAME: ${{ steps.get_release_info.outputs.version_name }} | ||||||||||
| _VERSION_NUMBER: ${{ steps.get_release_info.outputs.version_number }} | ||||||||||
| _TARGET_COMMIT: ${{ steps.get_release_branch.outputs.release_branch }} | ||||||||||
| _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/*/*") | ||||||||||
|
|
||||||||||
| # 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 }} | ||||||||||
| _RELEASE_ID: ${{ steps.create_release.outputs.release_id_from_url }} | ||||||||||
| run: | | ||||||||||
| 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) | ||||||||||
|
|
||||||||||
| # Update release description with product release notes and builds source | ||||||||||
| updated_body="# Overview | ||||||||||
| ${product_release_notes} | ||||||||||
|
|
||||||||||
| ${current_body} | ||||||||||
| **Builds Source:** https://github.com/${{ github.repository }}/actions/runs/$ARTIFACT_RUN_ID" | ||||||||||
|
|
||||||||||
| 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" | ||||||||||
|
|
||||||||||
| - name: Add Release Summary | ||||||||||
| env: | ||||||||||
| _RELEASE_TAG: ${{ steps.get_release_info.outputs.tag_name }} | ||||||||||
| _LAST_RELEASE_TAG: ${{ steps.get_release_info.outputs.last_release_tag }} | ||||||||||
| _VERSION_NAME: ${{ steps.get_release_info.outputs.version_name }} | ||||||||||
| _VERSION_NUMBER: ${{ steps.get_release_info.outputs.version_number }} | ||||||||||
| _RELEASE_BRANCH: ${{ steps.get_release_branch.outputs.release_branch }} | ||||||||||
| _RELEASE_URL: ${{ steps.update_release_description.outputs.release_url }} | ||||||||||
| run: | | ||||||||||
| { | ||||||||||
| echo "# :fish_cake: Release ready at:" | ||||||||||
| echo "$_RELEASE_URL" | ||||||||||
| echo "" | ||||||||||
| } >> "$GITHUB_STEP_SUMMARY" | ||||||||||
|
|
||||||||||
| if [[ "$_VERSION_NAME" == "0.0.0" || "$_VERSION_NUMBER" == "0" ]]; then | ||||||||||
| { | ||||||||||
| echo "> [!CAUTION]" | ||||||||||
| echo "> Version name or number wasn't previously found and a default value was used. You'll need to manually update the release Title, Tag and Description, specifically, the \"Full Changelog\" link." | ||||||||||
| echo "" | ||||||||||
| } >> "$GITHUB_STEP_SUMMARY" | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| { | ||||||||||
| echo ":clipboard: Confirm that the defined GitHub Release options are correct:" | ||||||||||
| echo " * :bookmark: New tag name: \`$_RELEASE_TAG\`" | ||||||||||
| echo " * :palm_tree: Target branch: \`$_RELEASE_BRANCH\`" | ||||||||||
| echo " * :ocean: Previous tag set in the description \"Full Changelog\" link: \`$_LAST_RELEASE_TAG\`" | ||||||||||
| echo " * :white_check_mark: Description has automated release notes and they match the commits in the release branch" | ||||||||||
| echo "> [!NOTE]" | ||||||||||
| echo "> Commits directly pushed to branches without a Pull Request won't appear in the automated release notes." | ||||||||||
| } >> "$GITHUB_STEP_SUMMARY" | ||||||||||
| azure_subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||||||||||
| azure_tenant_id: ${{ secrets.AZURE_TENANT_ID }} | ||||||||||
| azure_client_id: ${{ secrets.AZURE_CLIENT_ID }} | ||||||||||
| artifact_run_id: ${{ github.event.inputs.artifact-run-id }} | ||||||||||
| release_ticket_id: ${{ github.event.inputs.release-ticket-id }} | ||||||||||
|
Comment on lines
+28
to
+29
Contributor
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. π΅ SUGGESTED: For
Suggested change
|
||||||||||
| task: release-android | ||||||||||
| description: "Trigger release of Android artifacts" | ||||||||||
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.
β QUESTION: The previous version of this workflow enforced a branch-protection guard before creating a release β it rejected the run unless the artifact's
headBranchwasmainor matchedrelease/*("Releases must be created from protected branches"). That check is removed here. Is that guard now enforced downstream inbitwarden/gh-actions/trigger-actions/ therelease-androidtask in the deploy repo? Just want to confirm we're not dropping the protection that releases only originate from protected branches.