-
Notifications
You must be signed in to change notification settings - Fork 1
149 lines (127 loc) · 5.73 KB
/
publish.yml
File metadata and controls
149 lines (127 loc) · 5.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Publish to VS Marketplace
on:
workflow_dispatch:
permissions:
contents: write
actions: read
jobs:
publish:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: 1. Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v6
with:
workflow: release_build_and_deploy.yml
workflow_conclusion: success
- name: 2. Parse Artifact Manifest
id: artifact_manifest
uses: ActionsTools/read-json-action@main
with:
file_path: ./artifact/CodingWithCalvin.OpenInNotepadPlusPlus.info
- name: 3. Create Tag & Release
uses: ncipollo/release-action@v1.14.0
with:
artifacts: ./artifact/CodingWithCalvin.OpenInNotepadPlusPlus.vsix
generateReleaseNotes: true
makeLatest: true
commit: ${{ steps.artifact_manifest.outputs.sha }}
tag: ${{ steps.artifact_manifest.outputs.version }}
- name: 4. Publish Release to Marketplace
if: success()
uses: CodingWithCalvin/GHA-VSMarketplacePublisher@v1
with:
marketplace-pat: ${{ secrets.VS_PAT }}
publish-manifest-path: ./resources/extension.manifest.json
vsix-path: ./artifact/CodingWithCalvin.OpenInNotepadPlusPlus.vsix
- name: 5. Post to BlueSky
if: success()
run: |
VERSION="${{ steps.artifact_manifest.outputs.version }}"
RELEASE_URL="https://github.com/${{ github.repository }}/releases/tag/$VERSION"
MARKETPLACE_URL="https://marketplace.visualstudio.com/items?itemName=CodingWithCalvin.VS-OpenInNotepadPlusPlus"
# Authenticate with BlueSky
echo "Authenticating with BlueSky..."
AUTH_RESPONSE=$(curl -s -X POST https://bsky.social/xrpc/com.atproto.server.createSession \
-H "Content-Type: application/json" \
-d "{\"identifier\": \"${{ secrets.BLUESKY_USERNAME }}\", \"password\": \"${{ secrets.BLUESKY_APP_PASSWORD }}\"}")
ACCESS_TOKEN=$(echo "$AUTH_RESPONSE" | jq -r '.accessJwt')
DID=$(echo "$AUTH_RESPONSE" | jq -r '.did')
if [ -z "$ACCESS_TOKEN" ] || [ "$ACCESS_TOKEN" == "null" ]; then
echo "Error: Failed to authenticate with BlueSky"
echo "Response: $AUTH_RESPONSE"
exit 1
fi
echo "✓ Authenticated as $DID"
# Create post text
POST_TEXT="🚀 Open in Notepad++ v${VERSION} for #VisualStudio has been released!"
POST_TEXT="${POST_TEXT}"$'\n\n'"Check out the release notes here!"
POST_TEXT="${POST_TEXT}"$'\n\n'"Marketplace: ${MARKETPLACE_URL}"
echo "Post text: $POST_TEXT"
# Get current timestamp in ISO 8601 format
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# Calculate facets (byte positions for hashtags and links)
echo "Calculating facets for links and hashtags..."
export POST_TEXT
export RELEASE_URL
FACETS=$(python3 -c "
import json, re, os
text = os.environ['POST_TEXT']
release_url = os.environ['RELEASE_URL']
facets = []
# Add hashtag facets
for m in re.finditer(r'#(\w+)', text):
facets.append({
'index': {'byteStart': len(text[:m.start()].encode('utf-8')), 'byteEnd': len(text[:m.start()+len(m.group(0))].encode('utf-8'))},
'features': [{'\$type': 'app.bsky.richtext.facet#tag', 'tag': m.group(1)}]
})
# Add link facets for URLs
for m in re.finditer(r'https?://[^\s]+', text):
facets.append({
'index': {'byteStart': len(text[:m.start()].encode('utf-8')), 'byteEnd': len(text[:m.start()+len(m.group())].encode('utf-8'))},
'features': [{'\$type': 'app.bsky.richtext.facet#link', 'uri': m.group()}]
})
# Add link facet for 'Check out the release notes here!'
release_text = 'Check out the release notes here!'
idx = text.find(release_text)
if idx >= 0:
facets.append({
'index': {'byteStart': len(text[:idx].encode('utf-8')), 'byteEnd': len(text[:idx+len(release_text)].encode('utf-8'))},
'features': [{'\$type': 'app.bsky.richtext.facet#link', 'uri': release_url}]
})
print(json.dumps(facets))
")
echo "Facets: $FACETS"
# Create the post using jq to properly escape JSON
echo "Creating BlueSky post..."
POST_RESPONSE=$(jq -n \
--arg did "$DID" \
--arg text "$POST_TEXT" \
--arg timestamp "$TIMESTAMP" \
--argjson facets "$FACETS" \
'{
repo: $did,
collection: "app.bsky.feed.post",
record: {
text: $text,
facets: $facets,
createdAt: $timestamp,
"$type": "app.bsky.feed.post"
}
}' | curl -s -X POST https://bsky.social/xrpc/com.atproto.repo.createRecord \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d @-)
POST_URI=$(echo "$POST_RESPONSE" | jq -r '.uri')
if [ -z "$POST_URI" ] || [ "$POST_URI" == "null" ]; then
echo "Error: Failed to create BlueSky post"
echo "Response: $POST_RESPONSE"
exit 1
fi
# Extract the post ID from the URI
POST_ID=$(echo "$POST_URI" | sed 's|.*/||')
POST_URL="https://bsky.app/profile/${{ secrets.BLUESKY_USERNAME }}/post/$POST_ID"
echo "✓ Posted to BlueSky: $POST_URL"
shell: bash