forked from scratchfoundation/scratch-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (119 loc) · 4.97 KB
/
Copy pathpublish.yml
File metadata and controls
142 lines (119 loc) · 4.97 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
name: Publish
on:
release:
types: [published]
jobs:
ci:
uses: ./.github/workflows/ci.yml
cd:
needs:
- ci
runs-on: ubuntu-latest
steps:
- name: Debug info
run: |
cat <<EOF
Release tag name: ${{ github.event.release.tag_name }}
Release target commit-ish: ${{ github.event.release.target_commitish }}
EOF
- name: Determine NPM tag
id: npm_tag
shell: bash
run: |
case ${{ github.event.release.target_commitish }} in
develop | main | master)
if [[ ${{ github.event.release.prerelease }} == true ]]; then
npm_tag=beta
else
npm_tag=latest
fi
;;
*)
# use the branch name
npm_tag="${{ github.event.release.target_commitish }}"
;;
esac
echo "Determined NPM tag: [$npm_tag]"
echo "npm_tag=${npm_tag}" >> "$GITHUB_OUTPUT"
- name: Check NPM tag
run: |
if [ -z "${{ steps.npm_tag.outputs.npm_tag }}" ]; then
echo "Refusing to publish with empty NPM tag."
exit 1
fi
- name: Config GitHub user
shell: bash
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'github-actions@localhost'
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with:
token: ${{ secrets.PAT_RELEASE_PUSH }} # persists the token for pushing to the repo later
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
with:
cache: 'npm'
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
- uses: ./.github/actions/install-dependencies
- name: Update the version in the package files
shell: bash
run: |
GIT_TAG="${{github.event.release.tag_name}}"
NEW_VERSION="${GIT_TAG/v/}"
npm version "$NEW_VERSION" --no-git-tag-version
git add package* && git commit -m "chore(release): $NEW_VERSION [skip ci]"
# Install dependencies after the version update so that
# the build outputs refer to the newest version of inner packages
- uses: ./.github/actions/install-dependencies
- name: Publish scratch-svg-renderer
run: |
npm run build --workspace @scratch/scratch-svg-renderer
npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-svg-renderer
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish scratch-render
run: |
npm run build --workspace @scratch/scratch-render
npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-render
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish scratch-vm
run: |
npm run build --workspace @scratch/scratch-vm
npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-vm
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish scratch-gui
run: |
cp ./packages/scratch-gui/package.json ./packages/scratch-gui/package-copy.json
jq 'del(.exports["./standalone"])' ./packages/scratch-gui/package.json | npx sponge ./packages/scratch-gui/package.json
npm run build:dist --workspace @scratch/scratch-gui
npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-gui
mv ./packages/scratch-gui/package-copy.json ./packages/scratch-gui/package.json
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish scratch-gui-standalone
run: |
bash ./scripts/prepare-standalone-gui.sh
npm --workspace=@scratch/scratch-gui-standalone run clean && npm --workspace=@scratch/scratch-gui-standalone run build:dist-standalone
npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-gui-standalone
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Push to develop
shell: bash
run: |
git fetch origin develop
TAG_NAME="${{github.event.release.tag_name}}"
LAST_COMMIT_ID="$(git rev-parse $TAG_NAME)"
DEVELOP_COMMIT_ID="$(git rev-parse origin/develop)"
if [ "$LAST_COMMIT_ID" = "$DEVELOP_COMMIT_ID" ]; then
git push origin HEAD:develop
else
echo "Not pushing to develop because the tag we're operating on is behind"
fi
# See https://stackoverflow.com/a/24849501
- name: Change connected commit on release
shell: bash
run: |
git tag -f "${{github.event.release.tag_name}}" HEAD
git push -f origin "refs/tags/${{github.event.release.tag_name}}"