-
Notifications
You must be signed in to change notification settings - Fork 83
[FSSDK-9999] add release workflow #906
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1fa4a0a
[FSSDK-9999] add release workflow
raju-opti f3ecd73
add jellyfish step
raju-opti f5cca13
remove dry run
raju-opti 9be487a
capitalize
raju-opti d01f48d
add workflow_dispatch event
raju-opti 17c1c6b
add conidtional jellyfish reporting
raju-opti 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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Publish SDK to NPM | ||
|
||
on: | ||
release: | ||
types: [published, edited] | ||
mikechu-optimizely marked this conversation as resolved.
Show resolved
Hide resolved
|
||
workflow_dispatch: {} | ||
|
||
jobs: | ||
publish: | ||
name: Publish to NPM | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event_name == 'workflow_dispatch' || !github.event.release.draft }} | ||
steps: | ||
- name: Checkout branch | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
mikechu-optimizely marked this conversation as resolved.
Show resolved
Hide resolved
|
||
registry-url: "https://registry.npmjs.org/" | ||
always-auth: "true" | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- id: latest-release | ||
name: Export latest release git tag | ||
run: | | ||
echo "latest-release-tag=$(curl -qsSL \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||
"${{ github.api_url }}/repos/${{ github.repository }}/releases/latest" \ | ||
| jq -r .tag_name)" >> $GITHUB_OUTPUT | ||
|
||
- id: npm-tag | ||
mikechu-optimizely marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name: Determine NPM tag | ||
run: | | ||
VERSION=$(jq -r '.version' package.json) | ||
LATEST_RELEASE_TAG="${{ steps.latest-release.outputs['latest-release-tag']}}" | ||
|
||
if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then | ||
GITHUB_REF=${{ github.ref }} | ||
RELEASE_TAG=${GITHUB_REF#refs/tags/} | ||
else | ||
RELEASE_TAG="${{ github.event.release.tag_name }}" | ||
fi | ||
|
||
if [[ $RELEASE_TAG == $LATEST_RELEASE_TAG ]]; then | ||
echo "npm-tag=latest" >> "$GITHUB_OUTPUT" | ||
elif [[ "$VERSION" == *"-beta"* ]]; then | ||
echo "npm-tag=beta" >> "$GITHUB_OUTPUT" | ||
elif [[ "$VERSION" == *"-alpha"* ]]; then | ||
echo "npm-tag=alpha" >> "$GITHUB_OUTPUT" | ||
elif [[ "$VERSION" == *"-rc"* ]]; then | ||
echo "npm-tag=rc" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "npm-tag=v$(echo $VERSION | awk -F. '{print $1}')-latest" >> "$GITHUB_OUTPUT" | ||
fi | ||
|
||
- id: release | ||
name: Test, build and publish to npm | ||
env: | ||
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} | ||
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | ||
run: | | ||
if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then | ||
DRY_RUN="--dry-run" | ||
fi | ||
npm publish --tag=${{ steps.npm-tag.outputs['npm-tag'] }} $DRY_RUN | ||
|
||
- name: Report results to Jellyfish | ||
uses: optimizely/jellyfish-deployment-reporter-action@main | ||
if: ${{ always() && github.event_name == 'release' && (steps.release.outcome == 'success' || steps.release.outcome == 'failure') }} | ||
with: | ||
jellyfish_api_token: ${{ secrets.JELLYFISH_API_TOKEN }} | ||
mikechu-optimizely marked this conversation as resolved.
Show resolved
Hide resolved
|
||
is_successful: ${{ steps.release.outcome == 'success' }} |
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.
Uh oh!
There was an error while loading. Please reload this page.