forked from AssemblyScript/assemblyscript
-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (83 loc) · 2.8 KB
/
publish.yml
File metadata and controls
83 lines (83 loc) · 2.8 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
name: Publish
on:
schedule:
- cron: '0 0 * * *'
jobs:
publish:
name: "Packages"
if: github.repository == 'AssemblyScript/assemblyscript'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
ref: release
- uses: dcodeIO/setup-node-nvm@master
with:
node-version: current
- name: Merge master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git remote set-url origin "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git fetch origin
git merge origin/master
- name: Install dependencies
run: npm ci
- name: Build distribution files
run: |
npm run clean
npm run build
- name: Test distribution files
run: npm test
- name: Set up version
run: |
VERSION=$(node -e "console.log(require('./package.json').version)")
git add --force dist/*
if git rev-parse v$VERSION >/dev/null 2>&1; then
VERSION=$VERSION-nightly.$(date "+%Y%m%d")
if git rev-parse v$VERSION >/dev/null 2>&1; then
echo "Nightly $VERSION does already exist."
exit 1
fi
echo ::set-env name=CHANNEL::nightly
echo "Committing nightly ($VERSION) ..."
git commit -m "Nightly v$VERSION"
npm version $VERSION --no-git-tag-version --force
else
echo ::set-env name=CHANNEL::latest
echo "Committing release ($VERSION) ..."
git commit --allow-empty -m "Release v$VERSION"
fi
echo ::set-env name=VERSION::$VERSION
cd lib/loader
npm version $VERSION --no-git-tag-version --force
cd ../..
- name: Create tag and push distribution files
run: |
git tag v$VERSION
git push origin release
git push origin v$VERSION
- name: Publish to npm
env:
NPM_REGISTRY: "registry.npmjs.org"
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm config set "//${NPM_REGISTRY}/:_authToken=${NPM_AUTH_TOKEN}"
npm publish --tag $CHANNEL
cd lib/loader
npm publish --tag $CHANNEL --access public
cd ../..
- name: Publish to gpr
env:
NPM_REGISTRY: "npm.pkg.github.com"
NPM_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm config set "//${NPM_REGISTRY}/:_authToken=${NPM_AUTH_TOKEN}"
sed -i 's/"assemblyscript"/"@assemblyscript\/assemblyscript"/' package.json
sed -i 's/"assemblyscript"/"@assemblyscript\/assemblyscript"/' package-lock.json
npm publish --registry=https://${NPM_REGISTRY}
cd lib/loader
npm publish --registry=https://${NPM_REGISTRY}
cd ../..