Release #58
This file contains hidden or 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
| name: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| releaseType: | |
| description: 'Release Type' | |
| required: true | |
| type: choice | |
| default: 'patch' | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| jobs: | |
| release: | |
| runs-on: macos-latest | |
| steps: | |
| - name: Clone Repository | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node version | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 18 | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Install VSCE | |
| run: npm install -g @vscode/vsce | |
| - name: Set up secrets | |
| run: | | |
| rm -f src/env-secrets.ts | |
| echo "export const SEGMENT_WRITE_KEY = '${{ secrets.SEGMENT_WRITE_KEY }}'" >> src/env-secrets.ts | |
| - name: Create Changelog | |
| run: | | |
| git log $(git describe --tags --abbrev=0)..HEAD --oneline &> ${{ github.workspace }}-CHANGELOG.txt | |
| cat ${{ github.workspace }}-CHANGELOG.txt | |
| - name: Get Current Version Number | |
| run: | | |
| CURRENT_VERSION=$(git describe --tags --abbrev=0 | sed 's/v//') | |
| echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV | |
| - name: Compile New Version | |
| env: | |
| RELEASE_TYPE: ${{ github.event.inputs.releaseType }} | |
| run: | | |
| RELEASE_VERSION=$(npx semver $CURRENT_VERSION -i $RELEASE_TYPE) | |
| echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV | |
| echo "Bump to v$RELEASE_VERSION" | |
| - name: Version Package | |
| run: | | |
| git status | |
| npm version $RELEASE_VERSION --no-git-tag-version | |
| git tag -a v$RELEASE_VERSION -m "v$RELEASE_VERSION" | |
| - name: Package Extension | |
| run: vsce package $RELEASE_VERSION --no-git-tag-version --no-update-package-json -o "./releases/codacy-$RELEASE_VERSION.vsix" | |
| - name: Publish to Visual Studio Marketplace | |
| run: vsce publish --packagePath "./releases/codacy-$RELEASE_VERSION.vsix" --no-git-tag-version --no-update-package-json -p ${{ secrets.VSC_MKTP_PAT }} | |
| - name: Publish to Open VSX Registry | |
| continue-on-error: true | |
| uses: HaaLeo/publish-vscode-extension@v1 | |
| with: | |
| preRelease: false | |
| pat: ${{ secrets.OPEN_VSX_TOKEN }} | |
| extensionFile: ./releases/codacy-${{ env.RELEASE_VERSION }}.vsix | |
| - name: Push Tags | |
| run: | | |
| git log -1 --stat | |
| git push origin main --tags | |
| - run: | | |
| export GIT_TAG=$(git describe --tags --abbrev=0) | |
| echo "GIT_TAG=$GIT_TAG" >> $GITHUB_ENV | |
| - name: GitHub Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| artifacts: './releases/codacy-*' | |
| bodyFile: ${{ github.workspace }}-CHANGELOG.txt | |
| tag: ${{ env.GIT_TAG }} | |
| prerelease: false | |
| - name: Send Slack notification | |
| id: slack | |
| uses: slackapi/slack-github-action@v1.24.0 | |
| with: | |
| payload: | | |
| { | |
| "version": "${{ env.RELEASE_VERSION }}", | |
| "releaseType": "${{ github.event.inputs.releaseType }}" | |
| } | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |