fix: update asset name in release workflow to remove solution version #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################## | |
### Basic SharePoint Framework Build Pipeline (SPFx) ### | |
######################################################## | |
name: "Basic SharePoint Framework Build Pipeline (SPFx)" | |
permissions: | |
contents: write | |
packages: write | |
on: | |
push: | |
branches: | |
- "main" | |
jobs: | |
spfx-build: | |
name: "SPFx Build solution" | |
runs-on: ubuntu-latest | |
outputs: | |
solution_version: ${{ env.SOLUTION_VERSION }} | |
release_name: ${{ env.RELEASE_NAME }} | |
sppkg_path: ${{ env.SPPKG_PATH }} | |
sppkg_filename: ${{ env.SPPKG_FILENAME }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 18.x | |
- name: Install node packages | |
run: npm install | |
- name: Install Gulp (globally) | |
run: npm install -g gulp | |
- name: build solution | |
run: gulp build | |
- name: create solution package (.sppkg) | |
run: | | |
gulp bundle --ship | |
gulp package-solution --ship | |
- name: Set Solution parameters | |
run: | | |
SOLUTION_VERSION=$(jq -r '.solution.version' ./config/package-solution.json) | |
echo "SOLUTION_VERSION=${SOLUTION_VERSION}" >> $GITHUB_ENV | |
echo "RELEASE_NAME=$(date +'%Y%m').${GITHUB_RUN_NUMBER}-v${SOLUTION_VERSION}" >> $GITHUB_ENV | |
SPPKG_PATH=$(find ./sharepoint/solution -name "*.sppkg" -type f) | |
echo "SPPKG_PATH=${SPPKG_PATH}" >> $GITHUB_ENV | |
SPPKG_FILENAME=$(basename ${SPPKG_PATH}) | |
echo "SPPKG_FILENAME=${SPPKG_FILENAME}" >> $GITHUB_ENV | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.SPPKG_FILENAME }} | |
path: ${{ env.SPPKG_PATH }} | |
release: | |
needs: spfx-build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ needs.spfx-build.outputs.sppkg_filename }} | |
- name: Set new Version Tag and Publish Release | |
uses: actions/create-release@v1 | |
id: create_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "v${{ needs.spfx-build.outputs.solution_version }}" | |
release_name: ${{ needs.spfx-build.outputs.release_name }} | |
body: "Release ${{ needs.spfx-build.outputs.solution_version }}" | |
draft: false | |
prerelease: false | |
- 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: ${{ needs.spfx-build.outputs.sppkg_filename }} | |
asset_name: "${{ needs.spfx-build.outputs.sppkg_filename }}" | |
asset_content_type: application/zip |