|
1 | 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node |
2 | 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions |
3 | 3 |
|
4 | | -name: Azure SDK copy package to drop |
| 4 | +name: Create release and publish to drop |
5 | 5 |
|
6 | 6 | on: workflow_dispatch |
7 | 7 |
|
8 | 8 | jobs: |
9 | | -# test: |
10 | | -# runs-on: ${{ matrix.os }} |
11 | | -# strategy: |
12 | | -# matrix: |
13 | | -# os: [macos-latest, windows-latest, ubuntu-18.04] |
14 | | -# node-version: [10.x, 12.x, 14.x] |
15 | | -# |
16 | | -# steps: |
17 | | -# - uses: actions/checkout@v2 |
18 | | -# - name: Use Node.js ${{ matrix.node-version }} |
19 | | -# uses: actions/setup-node@v1 |
20 | | -# with: |
21 | | -# node-version: ${{ matrix.node-version }} |
22 | | -# - run: npm ci |
23 | | -# - run: npm test |
24 | | - |
25 | | - package: |
26 | | -# needs: [test] |
| 9 | + test: |
| 10 | + name: Run tests |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + os: [macos-latest, windows-latest, ubuntu-18.04] |
| 15 | + node-version: [10.x, 12.x, 14.x] |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v2 |
| 19 | + with: |
| 20 | + ref: main |
| 21 | + - name: Use Node.js ${{ matrix.node-version }} |
| 22 | + uses: actions/setup-node@v1 |
| 23 | + with: |
| 24 | + node-version: ${{ matrix.node-version }} |
| 25 | + - run: npm ci |
| 26 | + - run: npm test |
| 27 | + |
| 28 | + packageAndRelease: |
| 29 | + needs: [ test ] |
| 30 | + name: Package / tag / release |
27 | 31 | runs-on: ubuntu-18.04 |
28 | 32 | steps: |
29 | 33 | - uses: actions/checkout@v2 |
| 34 | + with: |
| 35 | + ref: main |
30 | 36 | - name: Use Node.js 14.x |
31 | 37 | uses: actions/setup-node@v1 |
32 | 38 | with: |
33 | 39 | node-version: 14.x |
34 | 40 |
|
35 | 41 | - run: npm ci |
36 | 42 | - run: npm run build |
37 | | -# - run: npm version prerelease --preid=ci-$GITHUB_RUN_ID --no-git-tag-version |
38 | 43 | - run: npm pack |
| 44 | + |
39 | 45 | - name: Upload |
40 | 46 | uses: actions/upload-artifact@v2 |
41 | 47 | with: |
42 | 48 | name: package |
43 | 49 | path: "*.tgz" |
44 | 50 |
|
45 | | - copy: |
46 | | - name: "Copy to Azure SDK Partner Pipeline Drop" |
47 | | - needs: [package] |
48 | | - runs-on: ubuntu-18.04 |
49 | | - steps: |
50 | | - - name: Upload |
51 | | - uses: actions/download-artifact@v2 |
| 51 | + - name: Get package version |
| 52 | + run: echo "NPM_PACKAGE_VERSION=$(jq -r ".version" package.json)" >> $GITHUB_ENV |
| 53 | + - name: Get package path |
| 54 | + run: echo "NPM_PACKAGE_PATH=$(ls *.tgz)" >> $GITHUB_ENV |
| 55 | + - name: Get commit SHA |
| 56 | + run: echo "GIT_COMMIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV |
| 57 | + |
| 58 | + - name: Create tag |
| 59 | + uses: actions/github-script@v3 |
52 | 60 | with: |
53 | | - name: package |
54 | | - - run: | |
55 | | - ls -la |
56 | | - # azcopy /Source:. /Dest:$AZURE_SDK_DROP_URL/azure-staticwebapps/npm/ |
| 61 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + script: | |
| 63 | + github.git.createRef({ |
| 64 | + owner: context.repo.owner, |
| 65 | + repo: context.repo.repo, |
| 66 | + ref: "refs/tags/v${{ env.NPM_PACKAGE_VERSION }}", |
| 67 | + sha: "${{ env.GIT_COMMIT_SHA }}" |
| 68 | + }) |
| 69 | +
|
| 70 | + - name: Create Release |
| 71 | + id: create_release |
| 72 | + uses: actions/create-release@v1 |
57 | 73 | env: |
58 | | - AZURE_SDK_DROP_URL: ${{secrets.AZURE_SDK_DROP_URL}} |
| 74 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + with: |
| 76 | + tag_name: v${{ env.NPM_PACKAGE_VERSION }} |
| 77 | + release_name: v${{ env.NPM_PACKAGE_VERSION }} |
| 78 | + draft: true |
| 79 | + prerelease: true |
| 80 | + |
| 81 | + - name: Upload Release Asset |
| 82 | + uses: actions/upload-release-asset@v1 |
| 83 | + env: |
| 84 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 85 | + with: |
| 86 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 87 | + asset_path: ${{ env.NPM_PACKAGE_PATH }} |
| 88 | + asset_name: ${{ env.NPM_PACKAGE_PATH }} |
| 89 | + asset_content_type: application/tar+gzip |
| 90 | + |
| 91 | + copy: |
| 92 | + name: "Copy to drop" |
| 93 | + needs: [ packageAndRelease ] |
| 94 | + runs-on: ubuntu-18.04 |
| 95 | + steps: |
| 96 | + - name: Download artifact |
| 97 | + uses: actions/download-artifact@v2 |
| 98 | + with: |
| 99 | + name: package |
| 100 | + |
| 101 | + - name: Upload to drop |
| 102 | + run: | |
| 103 | + ls -la |
| 104 | + PACKAGE_ID=`echo $(ls *.tgz) | sed -e 's/\.tgz$//'` |
| 105 | + echo $PACKAGE_ID |
| 106 | + az storage blob upload -n azure-staticwebapps/npm/$PACKAGE_ID/$(ls *.tgz) -c drops -f $(ls *.tgz) --account-name $AZURE_SDK_STORAGE_ACCOUNT_NAME --account-key $AZURE_SDK_DROP_ACCESS_KEY |
| 107 | + env: |
| 108 | + AZURE_SDK_STORAGE_ACCOUNT_NAME: ${{secrets.AZURE_SDK_STORAGE_ACCOUNT_NAME}} |
| 109 | + AZURE_SDK_DROP_ACCESS_KEY: ${{secrets.AZURE_SDK_DROP_ACCESS_KEY}} |
0 commit comments