Skip to content

Commit

Permalink
Only announce releases if Hydrogen is published
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdixon committed Nov 4, 2024
1 parent 692b4cb commit 98e5a12
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
name: Changelog PR or Release
outputs:
published: ${{ steps.changesets.outputs.published }}
# A JSON array to present the published packages. The format is [{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
latest: ${{ env.latest }}
latestBranch: ${{ env.latestBranch }}
steps:
Expand Down Expand Up @@ -94,37 +96,33 @@ jobs:
git commit -m "Update templates for dist"
git push origin HEAD:dist --force
slack_announcement:
extract_hydrogen_version:
needs: changelog
# Only announce if a release was published, and we're on the "latest" release branch
if: needs.changelog.outputs.published == 'true' && needs.changelog.outputs.latest == 'true'
runs-on: ubuntu-latest
outputs:
hydrogen_version: ${{ steps.extract_hydrogen_version.outputs.hydrogen_version }}
steps:
- name: Check out the code
uses: actions/checkout@v3

- name: Read Hydrogen version from package.json
id: read_package_json
working-directory: ./packages/hydrogen
- name: Extract Hydrogen version
id: extract_hydrogen_version
run: |
content=`cat ./package.json`
# the following lines are required for multi line json
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
# end of handling multi line json
echo "::set-output name=packageJson::$content"
- run: |
echo "HYDROGEN_VERSION=${{fromJSON(steps.read_package_json.outputs.packageJson).version}}" >> $GITHUB_ENV
PACKAGES='${{ needs.changelog.outputs.publishedPackages }}'
HYDROGEN_VERSION=$(echo $PACKAGES | jq -r '.[] | select(.name == "@shopify/hydrogen") | .version')
echo "hydrogen_version=$HYDROGEN_VERSION" >> $GITHUB_OUTPUT
slack_announcement:
needs: [changelog, extract_hydrogen_version]
# Only announce if a release was published, and we're on the "latest" release branch, and @shopify/hydrogen was published
if: needs.changelog.outputs.published == 'true' && needs.changelog.outputs.latest == 'true' && needs.extract_hydrogen_version.outputs.hydrogen_version != ''
runs-on: ubuntu-latest
steps:
- name: Post release announcement on Partner Slack
id: slack
uses: fjogeleit/http-request-action@v1
with:
url: ${{ secrets.SLACK_NOTIFICATION_URL }}
method: 'POST'
customHeaders: '{"Content-Type": "application/json"}'
data: "{\"version\": \"${{ env.HYDROGEN_VERSION }}\"}"
data: '{"version": "${{ needs.extract_hydrogen_version.outputs.hydrogen_version }}"}'

# sync_latest:
# needs: changelog
Expand Down

0 comments on commit 98e5a12

Please sign in to comment.