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

Re-work publish workflow to automatically set version if not defined #17

Merged
merged 7 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/build-wasm-internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,40 @@ jobs:
name: sdk-internal
path: ${{ github.workspace }}/languages/js/sdk-internal/*
if-no-files-found: error

trigger-wasm-publish:
name: Trigger WASM publish
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
needs: build
steps:
- name: Wait for Tests
uses: lewagon/wait-on-check-action@ccfb013c15c8afb7bf2b7c028fb74dc5a068cccc # v1.3.4
with:
ref: ${{ github.ref }}
check-name: "Rust tests / CI is green"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Azure - CI Subscription
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
with:
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}

- name: Retrieve github PAT secrets
id: retrieve-secret-pat
uses: bitwarden/gh-actions/get-keyvault-secrets@main
with:
keyvault: "bitwarden-ci"
secrets: "github-pat-bitwarden-devops-bot-repo-scope"

- name: Trigger WASM publish
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'bitwarden',
repo: 'sdk-internal',
workflow_id: 'publish-wasm-internal.yml',
ref: 'main',
})
Comment on lines +106 to +112
Copy link
Contributor

Choose a reason for hiding this comment

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

question: is this how GH actions work? You have to trigger another workflow using a script?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes ๐Ÿ˜ž

Copy link
Member

Choose a reason for hiding this comment

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

You can do it this way, but you can also use a workflow_call trigger in the workflow you want to call. There are pros and cons to each method.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- Dry Run
version:
description: "Release Version"
required: true
required: false

defaults:
run:
Expand All @@ -24,6 +24,8 @@ jobs:
setup:
name: Setup
runs-on: ubuntu-22.04
outputs:
release-version: ${{ steps.version-output.outputs.version }}
steps:
- name: Checkout repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
Expand All @@ -38,6 +40,17 @@ jobs:
exit 1
fi

- name: Version output
id: version-output
run: |
if [ -z ${{ inputs.version }} ]; then
BRANCH=${{ github.head_ref || github.ref_name }}
VERSION=0.2.0-${BRANCH/\//-}.${{ github.run_number }}
echo "version=$VERSION" >> $GITHUB_OUTPUT
else
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
fi

npm:
name: Publish NPM
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -74,9 +87,10 @@ jobs:

- name: Set version
run: |
npm version --no-git-tag-version ${{ inputs.version }}
npm version --no-git-tag-version $VERSION
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{needs.setup.outputs.release-version}}

- name: Setup NPM
run: |
Expand Down