Skip to content

Commit 4d2fbb7

Browse files
authored
chore: update Azure SDK workflow to release and publish
1 parent 3b67005 commit 4d2fbb7

1 file changed

Lines changed: 83 additions & 32 deletions

File tree

.github/workflows/azuresdkdrop.yml

Lines changed: 83 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,109 @@
11
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
33

4-
name: Azure SDK copy package to drop
4+
name: Create release and publish to drop
55

66
on: workflow_dispatch
77

88
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
2731
runs-on: ubuntu-18.04
2832
steps:
2933
- uses: actions/checkout@v2
34+
with:
35+
ref: main
3036
- name: Use Node.js 14.x
3137
uses: actions/setup-node@v1
3238
with:
3339
node-version: 14.x
3440

3541
- run: npm ci
3642
- run: npm run build
37-
# - run: npm version prerelease --preid=ci-$GITHUB_RUN_ID --no-git-tag-version
3843
- run: npm pack
44+
3945
- name: Upload
4046
uses: actions/upload-artifact@v2
4147
with:
4248
name: package
4349
path: "*.tgz"
4450

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
5260
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
5773
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

Comments
 (0)