Skip to content

Commit

Permalink
Social | Migrate remaining settings to script data (#40081)
Browse files Browse the repository at this point in the history
* Social | Migrate remaining settings to script data

* Remove the unnecessary props to useConnection

* Add changelog

* Be generous for unit tests

* Fix import

* Update class-publicize-script-data.php

* Clean up the social initial state from Jetpack plugin

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11776422450

Upstream-Ref: Automattic/jetpack@11d94d0
  • Loading branch information
jkguidaven authored and matticbot committed Nov 11, 2024
1 parent 065e7cf commit a5a23c6
Show file tree
Hide file tree
Showing 27 changed files with 1,134 additions and 756 deletions.
171 changes: 90 additions & 81 deletions .github/files/autorelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,43 @@

set -eo pipefail

: "${GH_TOKEN:?Build argument needs to be set and non-empty.}"
: "${GITHUB_REF:?Build argument needs to be set and non-empty.}"
: "${GITHUB_SHA:?Build argument needs to be set and non-empty.}"
: "${API_TOKEN_GITHUB:?Build argument needs to be set and non-empty.}"
: "${GITHUB_API_URL:?Build argument needs to be set and non-empty.}"
: "${GITHUB_REPOSITORY:?Build argument needs to be set and non-empty.}"

## Determine tag
if [[ ! "$GITHUB_REF" =~ ^refs/tags/v?[0-9]+(\.[0-9]+)+(-[a-z0-9._-]+)?$ ]]; then
echo "::error::Expected GITHUB_REF like \`refs/tags/v1.2.3\` or \`refs/tags/1.2.3\`, got \`$GITHUB_REF\`"
if [[ ! -f composer.json ]]; then
echo '::error::No composer.json. Did it get excluded from the mirror?'
exit 1
fi
TAG="${GITHUB_REF#refs/tags/}"

## Check for alphas
if [[ "$TAG" =~ -(alpha|a\.[0-9]*[02468])$ ]]; then
echo "Not creating a release for alpha version $TAG"
exit 0
fi
echo "Creating release for $TAG"
## Determine tag
ROLLING_MODE=
if [[ "$GITHUB_REF" =~ ^refs/tags/v?[0-9]+(\.[0-9]+)+(-[a-z0-9._-]+)?$ ]]; then
TAG="${GITHUB_REF#refs/tags/}"

## Determine slug and title format.
if [[ ! -f composer.json ]]; then
echo '::error::No composer.json. Did it get excluded from the mirror?'
## Check for alphas
if [[ "$TAG" =~ -(alpha|a\.[0-9]*[02468])$ ]]; then
echo "Not creating a release for alpha version $TAG"
exit 0
fi
elif [[ "$GITHUB_REF" == "refs/heads/trunk" ]]; then
if ! jq -e '.extra.autorelease["rolling-release"]? // false' composer.json > /dev/null; then
echo "::notice::Skipping trunk release because autorelease rolling mode is not enabled."
exit 0
fi
ROLLING_MODE=true
CURRENT_VER=$( sed -nEe 's/^## \[?([^]]*)\]? - .*/\1/;T;p;q' CHANGELOG.md || true )
GIT_SUFFIX=$( git log -1 --format="%ct.g%h" . )
TAG="$CURRENT_VER+rolling.$GIT_SUFFIX"
else
echo "::error::Expected GITHUB_REF like \`refs/tags/v1.2.3\` or \`refs/tags/1.2.3\` or \`refs/heads/trunk\` for rolling releases, got \`$GITHUB_REF\`"
exit 1
fi

SLUG="$(jq -r '.extra.autorelease.slug? // .extra["wp-plugin-slug"] // ( .name | sub( "^.*/"; "" ) )' composer.json)"
echo "Creating release for $TAG"

## Determine slug and title format.
SLUG="$(jq -r '.extra.autorelease.slug? // .extra["wp-plugin-slug"] // .extra["beta-plugin-slug"] // ( .name | sub( "^.*/"; "" ) )' composer.json)"
if [[ -z "$SLUG" ]]; then
echo '::error::Failed to get slug from composer.json.'
exit 1
Expand All @@ -48,76 +58,75 @@ echo "::group::Creating $SLUG.zip"
git archive -v --output="$SLUG.zip" --prefix="$SLUG/" HEAD 2>&1
echo "::endgroup::"

## Create the release note.
# Extract the changelog section.
echo "::group::Extracting release notes"
if [[ ! -f CHANGELOG.md ]]; then
echo '::endgroup::'
echo '::error::No CHANGELOG.md for release notes.'
exit 1
fi
SCRIPT="
/^## \\[?$(sed 's/[.\[\]\\*^$\/()+?{}|]/\\&/g' <<<"${TAG#v}")\\]? - / {
bc
if [[ -z "$ROLLING_MODE" ]]; then
## Create the release note.
# Extract the changelog section.
echo "::group::Extracting release notes"
if [[ ! -f CHANGELOG.md ]]; then
echo '::endgroup::'
echo '::error::No CHANGELOG.md for release notes.'
exit 1
fi
SCRIPT="
/^## \\[?$(sed 's/[.\[\]\\*^$\/()+?{}|]/\\&/g' <<<"${TAG#v}")\\]? - / {
bc
:a
n
/^## / {
q
}
:c
s/^## \[([^]]+)\]/## \1/
p
ba
}
"
ENTRY=$(sed -n -E -e "$SCRIPT" CHANGELOG.md)
if [[ -z "$ENTRY" ]]; then
echo '::endgroup::'
echo "::error::Failed to find section for ${TAG#v} in CHANGELOG.md"
exit 1
fi

# Strip unwanted sections.
SCRIPT="
:a
n
/^## / {
q
/^### .* This section will not be copied to readme\.txt/ {
:b
n
/^#/ ba
bb
}
:c
s/^## \[([^]]+)\]/## \1/
p
ba
}
"
ENTRY=$(sed -n -E -e "$SCRIPT" CHANGELOG.md)
if [[ -z "$ENTRY" ]]; then
echo '::endgroup::'
echo "::error::Failed to find section for ${TAG#v} in CHANGELOG.md"
exit 1
"
ENTRY=$(sed -n -E -e "$SCRIPT" <<<"$ENTRY")

echo "Release notes:"
echo "-----"
echo "$ENTRY"
echo "-----"
echo "::endgroup::"
else
## Using a brief explanation for the rolling release note.
ENTRY="### Rolling release based on the trunk branch."
fi

if [[ -n "$ROLLING_MODE" ]]; then
echo "::group::Deleting stale rolling release"

for R in $( gh release list --limit 100 --json tagName --jq '.[].tagName | select( contains( "rolling" ) )' ); do
echo "Found $R, deleting"
gh release delete "$R" --cleanup-tag --yes
done

echo "::endgroup::"
fi

# Strip unwanted sections.
SCRIPT="
:a
/^### .* This section will not be copied to readme\.txt/ {
:b
n
/^#/ ba
bb
}
p
"
ENTRY=$(sed -n -E -e "$SCRIPT" <<<"$ENTRY")

echo "Release notes:"
echo "-----"
echo "$ENTRY"
echo "-----"
echo "::endgroup::"

echo "::group::Creating release"
curl -v -L \
--write-out '%{response_code}' \
--output out.json \
--request POST \
--header "authorization: Bearer $API_TOKEN_GITHUB" \
--header 'content-type: application/json' \
--header 'accept: application/vnd.github.v3+json' \
--url "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases" \
--data "$(jq -n --arg tag "$TAG" --arg sha "$GITHUB_SHA" --arg title "$TITLE" --arg body "$ENTRY" '{ tag_name: $tag, target_commitish: $sha, name: $title, body: $body}')" \
2>&1 > code.txt
cat out.json
echo
[[ "$(<code.txt)" =~ ^2[0-9][0-9]$ ]] || exit 1
echo "::endgroup::"
gh release create "$TAG" "$SLUG.zip" \
--notes "$ENTRY" \
--target "$GITHUB_SHA" \
--title "$TITLE"

echo "::group::Uploading artifact to release"
curl -v --fail -L \
--request POST \
--header "authorization: Bearer $API_TOKEN_GITHUB" \
--header "content-type: application/zip" \
--url "$(jq -r '.upload_url | sub( "{\\?[^}]*}$"; "" )' out.json)?name=$SLUG.zip" \
--data-binary "@$SLUG.zip" \
2>&1
echo "::endgroup::"
4 changes: 3 additions & 1 deletion .github/workflows/autorelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
- 'v?[0-9]+.[0-9]+.[0-9]+-*'
- 'v?[0-9]+.[0-9]+.[0-9]+.[0-9]+'
- 'v?[0-9]+.[0-9]+.[0-9]+.[0-9]+-*'
branches:
- 'trunk'

jobs:
publish:
Expand All @@ -18,5 +20,5 @@ jobs:
- uses: actions/checkout@v4
- name: Create release
env:
API_TOKEN_GITHUB: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./.github/files/autorelease.sh
104 changes: 104 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,77 @@
## [3.1.11] - 2024-11-11
### Added
- Added post-build tests. [#38224]

### Changed
- Updated package dependencies. [#40000]

## [3.1.10] - 2024-10-25
### Changed
- Updated package dependencies. [#39893]

## [3.1.9] - 2024-10-14
### Fixed
- Add `key` in React example to make it more correct. [#39709]

## [3.1.8] - 2024-09-05
### Fixed
- Address React usage issues found by eslint in example.tsx. [#39214]

## [3.1.7] - 2024-08-23
### Changed
- Internal updates.

## [3.1.6] - 2024-08-21
### Fixed
- Revert recent SVG image optimizations. [#38981]

## [3.1.5] - 2024-08-19
### Fixed
- Lossless image optimization for images (should improve performance with no visible changes). [#38750]

## [3.1.4] - 2024-08-15
### Changed
- Updated package dependencies. [#38665]

## [3.1.3] - 2024-06-26
### Added
- Add: Substack logo [#38036]

## [3.1.2] - 2024-06-24
### Fixed
- Update logo color for Threads [#37977]

## [3.1.1] - 2024-06-14
### Changed
- Internal updates.

## [3.1.0] - 2024-06-13
### Added
- New icon: `deezer` [#37799]
- New icon: `discord` [#37799]
- New icon: `git` [#37799]
- New icon: `line` [#37799]
- New icon: `messenger` [#37799]
- New icon: `quora` [#37799]
- New icon: `snapchat` [#37799]
- New icon: `soundcloud` [#37799]
- New icon: `untappd` [#37799]
- New icon: `vk` [#37799]

### Fixed
- Build: Better error handling. [#37799]
- Build: Ensure consistent filename sort. [#37799]
- Build: Fonts folder was missing. [#37799]
- Build: React was missing example CSS file. [#37799]

## [3.0.2] - 2024-06-05
### Changed
- Updated package dependencies. [#37706]

## [3.0.1] - 2024-05-27
### Added
- Added TypeScript support. [#37528]

## [3.0.0] - 2024-05-23
### Added
- CSS file with encoded inline font is now automatically generated. [#36964]
Expand All @@ -21,61 +95,91 @@
- Example files are rewritten. [#36964]

## 2.5.9 - 2024-03-05

- New icon: `sms`

## 2.5.8 - 2023-12-20

- New icon: `bluesky`

## 2.5.7 - 2023-12-11

- Updated icon: `patreon`

## 2.5.6 - 2023-10-13

- Updated icon: `x`
- Removed unnecessary aria label attributes from Threads and X SVGs.

## 2.5.5 - 2023-09-15

- New icon: `x`

## 2.5.4 - 2023-07-10

- New icon: `threads`

## 2.5.3 - 2023-06-15

- New icon: `fediverse`
- New icon: `nextdoor`
- Updated dev dependencies and build tools.
- Updated icon font.

## 2.5.2 - 2023-02-01

- New icon: `mastadon`

## 2.5.1 - 2023-01-13

- React 18 support.

## 2.5.0 - 2022-02-01

- Added copy post url button.

## 2.4.0 - 2021-09-01

- Updated icon: `medium`
- Updated icon: `facebook`
- React 17 support.
- Update dev dependencies and build tools.

## 2.3.0 - 2021-01-27

- New icon: `medium-alt`
- New icon: `tiktok`
- New icon: `tiktok-alt`
- Updated icon: `medium`

## 2.2.0 - 2021-01-19

- New icon: `patreon`

## 2.1.2 - 2020-03-12

- Built the package with updated dependencies.

## 2.1.1 - 2020-03-10

- Build: Fixed bug where React component would render no icon at all (despite properly passed properties).

## 2.1.0 - 2018-01-31

- Build: Refactored (aligned build system with Gridicons).

[3.1.11]: https://github.com/Automattic/social-logos/compare/v3.1.10...v3.1.11
[3.1.10]: https://github.com/Automattic/social-logos/compare/v3.1.9...v3.1.10
[3.1.9]: https://github.com/Automattic/social-logos/compare/v3.1.8...v3.1.9
[3.1.8]: https://github.com/Automattic/social-logos/compare/v3.1.7...v3.1.8
[3.1.7]: https://github.com/Automattic/social-logos/compare/v3.1.6...v3.1.7
[3.1.6]: https://github.com/Automattic/social-logos/compare/v3.1.5...v3.1.6
[3.1.5]: https://github.com/Automattic/social-logos/compare/v3.1.4...v3.1.5
[3.1.4]: https://github.com/Automattic/social-logos/compare/v3.1.3...v3.1.4
[3.1.3]: https://github.com/Automattic/social-logos/compare/v3.1.2...v3.1.3
[3.1.2]: https://github.com/Automattic/social-logos/compare/v3.1.1...v3.1.2
[3.1.1]: https://github.com/Automattic/social-logos/compare/v3.1.0...v3.1.1
[3.1.0]: https://github.com/Automattic/social-logos/compare/v3.0.2...v3.1.0
[3.0.2]: https://github.com/Automattic/social-logos/compare/v3.0.1...v3.0.2
[3.0.1]: https://github.com/Automattic/social-logos/compare/v3.0.0...v3.0.1
[3.0.0]: https://github.com/Automattic/social-logos/compare/v2.5.9...v3.0.0
Loading

0 comments on commit a5a23c6

Please sign in to comment.