forked from pusher/pusher-js
-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (94 loc) · 3.64 KB
/
Copy pathrelease.yml
File metadata and controls
104 lines (94 loc) · 3.64 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
on:
push:
branches: [ master ]
jobs:
check-release-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Prepare tag
id: prepare_tag
continue-on-error: true
run: |
TAG=v$(jq -r '.version' package.json)
echo "TAG=$TAG" >> $GITHUB_ENV
if git tag | grep -q "^${TAG}$"; then
echo "Skipping because release tag already exists"
exit 1
fi
- name: Output
id: release_output
if: ${{ steps.prepare_tag.outcome == 'success' }}
run: |
echo "tag=${{ env.TAG }}" >> $GITHUB_OUTPUT
outputs:
tag: ${{ steps.release_output.outputs.tag }}
create-github-release:
runs-on: ubuntu-latest
needs: check-release-tag
if: ${{ needs.check-release-tag.outputs.tag }}
steps:
- uses: actions/checkout@v6
- name: Prepare tag
run: |
TAG=v$(jq -r '.version' package.json)
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Prepare description
run: |
csplit -s CHANGELOG.md "/##/" {1}
cat xx01 > CHANGELOG.tmp
- name: Create Release
run: |
gh release create "${{ env.TAG }}" \
--title "${{ env.TAG }}" \
--notes-file CHANGELOG.tmp
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-to-npm:
runs-on: ubuntu-latest
needs: create-github-release
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '20'
registry-url: https://registry.npmjs.org/
- run: npm install
- name: Publish if not already published
run: |
VERSION=$(jq -r '.version' package.json)
if npm view pusher-js@$VERSION version 2>/dev/null; then
echo "Version $VERSION already on npm, skipping."
else
npm publish --access public
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
upload-to-s3:
runs-on: ubuntu-latest
needs: create-github-release
steps:
- uses: actions/checkout@v6
- name: Upload to S3
run: |
VERSION=$(jq -r '.version' package.json | cut -d'.' -f1,2,3)
VERSION_MIN=$(jq -r '.version' package.json | cut -d'.' -f1,2)
grep -Eo '^[0-9]+\.[0-9]+\.[0-9]+' <<< $VERSION
aws s3 sync dist/web/ s3://${BUCKET_NAME}/latest/ --acl public-read --cache-control max-age=$MAX_AGE
aws s3 sync dist/worker/ s3://${BUCKET_NAME}/latest/ --acl public-read --cache-control max-age=$MAX_AGE
aws s3 sync dist/web/ s3://${BUCKET_NAME}/${VERSION}/ --acl public-read --cache-control max-age=$MAX_AGE
aws s3 sync dist/worker/ s3://${BUCKET_NAME}/${VERSION}/ --acl public-read --cache-control max-age=$MAX_AGE
aws s3 sync dist/web/ s3://${BUCKET_NAME}/${VERSION_MIN}/ --acl public-read --cache-control max-age=$MAX_AGE
aws s3 sync dist/worker/ s3://${BUCKET_NAME}/${VERSION_MIN}/ --acl public-read --cache-control max-age=$MAX_AGE
aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_DISTRIBUTION_ID} --paths "/latest/*" "/${VERSION}/*" "/${VERSION_MIN}/*"
env:
MAX_AGE: 2592000
BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
AWS_ACCESS_KEY_ID: ${{ secrets.PUSHERINOS_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.PUSHERINOS_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-west-2
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}