Skip to content

Create release and publish to drop #76

Create release and publish to drop

Create release and publish to drop #76

Workflow file for this run

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Create release and publish to drop
permissions: write-all
on: workflow_dispatch
jobs:
test:
name: Run tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-12, windows-latest, ubuntu-latest]
node-version: [14.x, 16.x, 18.x]
steps:
- uses: actions/checkout@v2
with:
ref: main
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm test
packageAndRelease:
needs: [ test ]
name: Package / tag / release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: main
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 18.x
- run: npm ci
- run: npm run build
- run: npm pack
- name: Upload
uses: actions/upload-artifact@v2
with:
name: package
path: "*.tgz"
- name: Get package version
run: echo "NPM_PACKAGE_VERSION=$(jq -r ".version" package.json)" >> $GITHUB_ENV
- name: Get package path
run: echo "NPM_PACKAGE_PATH=$(ls *.tgz)" >> $GITHUB_ENV
- name: Get commit SHA
run: echo "GIT_COMMIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Create tag
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/v${{ env.NPM_PACKAGE_VERSION }}",
sha: "${{ env.GIT_COMMIT_SHA }}"
})
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.NPM_PACKAGE_VERSION }}
release_name: v${{ env.NPM_PACKAGE_VERSION }}
draft: true
prerelease: true
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.NPM_PACKAGE_PATH }}
asset_name: ${{ env.NPM_PACKAGE_PATH }}
asset_content_type: application/tar+gzip
copy:
name: "Copy to drop"
needs: [ packageAndRelease ]
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: package
- name: 'Az CLI login'
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: 'Az CLI login'
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Upload to drop
run: |
ls -la
PACKAGE_ID=`echo $(ls *.tgz) | sed -e 's/\.tgz$//'`
echo $PACKAGE_ID
az storage blob upload -n azure-staticwebapps/npm/$PACKAGE_ID/$(ls *.tgz) -c drops -f $(ls *.tgz) --account-name $AZURE_SDK_STORAGE_ACCOUNT_NAME
env:
AZURE_SDK_STORAGE_ACCOUNT_NAME: ${{secrets.AZURE_SDK_STORAGE_ACCOUNT_NAME}}