|
| 1 | +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json |
| 2 | +--- |
| 3 | +name: Release |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + permissions: write-all |
| 14 | + runs-on: ubuntu-latest |
| 15 | + if: "github.repository_owner == 'fabric8-analytics' && startsWith(github.event.head_commit.message, '[release]')" |
| 16 | + name: Create & publish a release |
| 17 | + environment: production |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout repository |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + ssh-key: ${{ secrets.DEPLOY_KEY }} |
| 24 | + |
| 25 | + - name: Setup Node.js |
| 26 | + uses: actions/setup-node@v4 |
| 27 | + with: |
| 28 | + node-version: 20 |
| 29 | + registry-url: 'https://npm.pkg.github.com' |
| 30 | + env: |
| 31 | + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + |
| 33 | + - name: Create .npmrc |
| 34 | + run: | |
| 35 | + echo "@trustification:registry=https://npm.pkg.github.com" > ~/.npmrc |
| 36 | + echo "@fabric8-analytics:registry=https://npm.pkg.github.com" >> ~/.npmrc |
| 37 | + |
| 38 | + - name: Install @vscode/vsce |
| 39 | + run: npm i -g @vscode/vsce |
| 40 | + |
| 41 | + - name: Install Dependencies |
| 42 | + run: npm ci |
| 43 | + |
| 44 | + - name: VSCE package |
| 45 | + run: vsce package --out fabric8-analytics-${{ steps.bump.outputs.version }}-${{ github.run_number }}.vsix |
| 46 | + |
| 47 | + - name: Create SHA256 checksum |
| 48 | + run: | |
| 49 | + sha256sum fabric8-analytics-${{ steps.bump.outputs.version }}-${{ github.run_number }}.vsix > fabric8-analytics-${{ steps.bump.outputs.version }}-${{ github.run_number }}.vsix.sha256 |
| 50 | +
|
| 51 | + - name: Create a release |
| 52 | + id: new_release |
| 53 | + uses: actions/github-script@v7 |
| 54 | + with: |
| 55 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + script: | |
| 57 | + const repo_name = context.payload.repository.full_name |
| 58 | + const response = await github.request('POST /repos/' + repo_name + '/releases', { |
| 59 | + tag_name: '${{ steps.bump.outputs.version }}', |
| 60 | + name: '${{ steps.bump.outputs.version }}', |
| 61 | + body: '${{ steps.release-notes.outputs.notes }}', |
| 62 | + prerelease: false, |
| 63 | + generate_release_notes: true |
| 64 | + }) |
| 65 | + core.setOutput('upload_url', response.data.upload_url) |
| 66 | +
|
| 67 | + - name: Upload packages and checksums as release assets |
| 68 | + run: | |
| 69 | + for file in fabric8-analytics-${{ steps.bump.outputs.version }}-${{ github.run_number }}.vsix* |
| 70 | + do |
| 71 | + asset_name=$(basename "$file") |
| 72 | + upload_url=$(echo "${{ steps.new_release.outputs.upload_url }}" | sed "s/{?name,label}/?name=$asset_name/g") |
| 73 | + curl --data-binary @"$file" \ |
| 74 | + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 75 | + -H "Content-Type: application/octet-stream" \ |
| 76 | + "$upload_url" |
| 77 | + done |
| 78 | +
|
| 79 | + - name: Publish to VSCode Marketplace |
| 80 | + if: ${{ github.event.inputs.publishToMarketplace == 'true' }} |
| 81 | + run: | |
| 82 | + vsce publish --pat ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} --packagePath fabric8-analytics-${{ steps.bump.outputs.version }}-${{ github.run_number }}.vsix ${{ github.event.inputs.publishPreRelease == 'true' && '--pre-release' || '' }} |
| 83 | +
|
| 84 | + - name: Publish to Open VSX Registry |
| 85 | + if: ${{ github.event.inputs.publishToOVSX == 'true' }} |
| 86 | + run: | |
| 87 | + npx ovsx publish --pat ${{ secrets.OVSX_MARKETPLACE_TOKEN }} --packagePath fabric8-analytics-${{ steps.bump.outputs.version }}-${{ github.run_number }}.vsix ${{ github.event.inputs.publishPreRelease == 'true' && '--pre-release' || '' }} |
| 88 | +
|
0 commit comments