|
| 1 | +name: Publish Insiders |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 6 * * *' # every day at 6am |
| 6 | + repository_dispatch: |
| 7 | + types: [trigger-insiders-publish] |
| 8 | + |
| 9 | +jobs: |
| 10 | + check: |
| 11 | + name: Check for updates |
| 12 | + runs-on: ubuntu-latest |
| 13 | + outputs: |
| 14 | + status: ${{ steps.earlyexit.outputs.status }} |
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v2 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + - id: earlyexit |
| 21 | + run: | |
| 22 | + git config user.name github-actions |
| 23 | + git config user.email [email protected] |
| 24 | + if git rev-parse origin/insiders >/dev/null 2>&1; then |
| 25 | + insidersRef=$(git show-ref -s origin/insiders) |
| 26 | + headRef=$(git show-ref --head -s head) |
| 27 | + echo "origin/insiders" |
| 28 | + echo $insidersRef |
| 29 | + echo "HEAD" |
| 30 | + echo $headRef |
| 31 | + if [ "$insidersRef" = "$headRef" ]; then |
| 32 | + echo "No changes since last insiders build. Exiting." |
| 33 | + echo "::set-output name=status::unchanged" |
| 34 | + exit 0 |
| 35 | + else |
| 36 | + echo "Updating insiders" |
| 37 | + git push origin --delete insiders |
| 38 | + git checkout -b insiders |
| 39 | + git push origin insiders |
| 40 | + fi |
| 41 | + else |
| 42 | + echo "No insiders branch. Creating." |
| 43 | + git checkout -b insiders |
| 44 | + git push origin insiders |
| 45 | + fi |
| 46 | + echo "::set-output name=status::changed" |
| 47 | +
|
| 48 | + publish: |
| 49 | + name: Publish insiders |
| 50 | + needs: check |
| 51 | + runs-on: ubuntu-latest |
| 52 | + if: needs.check.outputs.status == 'changed' |
| 53 | + steps: |
| 54 | + - name: Checkout code |
| 55 | + uses: actions/checkout@v2 |
| 56 | + - name: Setup node |
| 57 | + uses: actions/setup-node@v1 |
| 58 | + with: |
| 59 | + node-version: '12.x' |
| 60 | + - name: Install |
| 61 | + run: yarn |
| 62 | + - name: Patch README.md |
| 63 | + run: node -e "var insert = fs.readFileSync('./README.insiders.md'); var d = fs.readFileSync('./README.md'); fs.writeFileSync('./README.md', insert + '\n' + d);" |
| 64 | + - name: Patch package.json |
| 65 | + run: | |
| 66 | + node -e "var d = new Date(new Date().toLocaleString('en-US', { timeZone: 'America/New_York' })); var p = require('./package.json'); p = JSON.stringify({...p, name: p.name + '-insiders', displayName: p.displayName + ' (Insiders)', version: '' + d.getFullYear() + '.' + (d.getMonth() + 1) + '.' + d.getDate() + String(d.getHours()).padStart(2, '0') }); fs.writeFileSync('./package.json', p);" |
| 67 | + - name: Setup Environment |
| 68 | + run: node -e "console.log('PACKAGE_VERSION=' + require('./package.json').version + '\nPACKAGE_NAME=' + require('./package.json').name + '-' + require('./package.json').version)" >> $GITHUB_ENV |
| 69 | + - name: Package extension |
| 70 | + run: yarn run pack |
| 71 | + - name: Publish extension |
| 72 | + run: yarn vsce publish --yarn --packagePath ./${{ env.PACKAGE_NAME }}.vsix -p ${{ secrets.MARKETPLACE_PAT }} |
| 73 | + - name: Publish artifact |
| 74 | + uses: actions/upload-artifact@v2 |
| 75 | + with: |
| 76 | + name: ${{ env.PACKAGE_NAME }}.vsix |
| 77 | + path: ./${{ env.PACKAGE_NAME }}.vsix |
0 commit comments