|
| 1 | +name: Publish |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + - cron: '0 5 * * *' |
| 5 | +jobs: |
| 6 | + publish: |
| 7 | + name: "Publish packages" |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - uses: actions/checkout@v1 |
| 11 | + with: |
| 12 | + ref: release |
| 13 | + - name: Merge master |
| 14 | + env: |
| 15 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 16 | + run: | |
| 17 | + git config user.name "GitHub Actions" |
| 18 | + git config user.email "[email protected]" |
| 19 | + git remote set-url origin "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" |
| 20 | + git fetch origin |
| 21 | + git merge origin/master |
| 22 | + - uses: actions/setup-node@v1 |
| 23 | + - name: Install dependencies |
| 24 | + run: npm ci |
| 25 | + - name: Build distribution files |
| 26 | + run: | |
| 27 | + npm run clean |
| 28 | + npm run build |
| 29 | + - name: Test distribution files |
| 30 | + run: npm test |
| 31 | + - name: Set up version |
| 32 | + run: | |
| 33 | + VERSION=$(node -e "console.log(require('./package.json').version)") |
| 34 | + git add --force dist/* |
| 35 | + if git rev-parse v$VERSION >/dev/null 2>&1; then |
| 36 | + VERSION=$VERSION-nightly.$(date "+%Y%m%d") |
| 37 | + if git rev-parse v$VERSION >/dev/null 2>&1; then |
| 38 | + echo "Nightly $VERSION does already exist." |
| 39 | + exit 1 |
| 40 | + fi |
| 41 | + echo ::set-env name=CHANNEL::nightly |
| 42 | + echo "Committing nightly ($VERSION) ..." |
| 43 | + git commit -m "Nightly v$VERSION" |
| 44 | + npm version $VERSION --no-git-tag-version --force |
| 45 | + else |
| 46 | + echo ::set-env name=CHANNEL::latest |
| 47 | + echo "Committing release ($VERSION) ..." |
| 48 | + git commit --allow-empty -m "Release v$VERSION" |
| 49 | + fi |
| 50 | + echo ::set-env name=VERSION::$VERSION |
| 51 | + - name: Create tag and push distribution files |
| 52 | + run: | |
| 53 | + git tag v$VERSION |
| 54 | + git push origin release |
| 55 | + git push origin v$VERSION |
| 56 | + # - name: Publish to npm |
| 57 | + # env: |
| 58 | + # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 59 | + # run: | |
| 60 | + # echo "npm publish --tag $CHANNEL" |
| 61 | + # cd ./lib/loader |
| 62 | + # npm version $VERSION --no-git-tag-version --force |
| 63 | + # echo "npm publish --tag $CHANNEL" |
| 64 | + # cd ../.. |
| 65 | + # - uses: actions/setup-node@v1 |
| 66 | + # with: |
| 67 | + # registry-url: 'https://npm.pkg.github.com' |
| 68 | + # scope: '@AssemblyScript' |
| 69 | + # - name: Publish to gpr |
| 70 | + # env: |
| 71 | + # NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + # run: | |
| 73 | + # echo "npm publish --tag $CHANNEL" |
| 74 | + # cd ./lib/loader |
| 75 | + # echo "npm publish --tag $CHANNEL" |
| 76 | + # cd ../.. |
0 commit comments