microsoft/vscode-loc
Publicmirrored fromhttps://github.com/microsoft/vscode-locAvailable
.github/workflows/release.yml
134lines · modecode
| 1 | on: |
| 2 | schedule: |
| 3 | # Run every Wednesday |
| 4 | - cron: 0 0 * * WED |
| 5 | workflow_dispatch: |
| 6 | |
| 7 | name: Release |
| 8 | |
| 9 | jobs: |
| 10 | setup-variables: |
| 11 | name: Setup variables |
| 12 | runs-on: ubuntu-latest |
| 13 | outputs: |
| 14 | tag: ${{ steps.get-tag.outputs.tag }} |
| 15 | version: ${{ steps.get-tag.outputs.version }} |
| 16 | matrix: ${{ steps.get-matrix.outputs.matrix }} |
| 17 | release_upload_url: ${{ steps.create-release.outputs.upload_url }} |
| 18 | steps: |
| 19 | - name: Checkout code |
| 20 | uses: actions/checkout@v2 |
| 21 | |
| 22 | - name: Get tag |
| 23 | id: get-tag |
| 24 | run: | |
| 25 | $version = (Get-Content ./i18n/vscode-language-pack-cs/package.json -Raw | ConvertFrom-Json).version |
| 26 | Write-Host "tag: release/$version" |
| 27 | Write-Host "::set-output name=tag::release/$version" |
| 28 | Write-Host "::set-output name=version::$version" |
| 29 | shell: pwsh |
| 30 | |
| 31 | - name: Commit tagger |
| 32 | uses: tvdias/github-tagger@v0.0.2 |
| 33 | with: |
| 34 | repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 35 | tag: ${{ steps.get-tag.outputs.tag }} |
| 36 | |
| 37 | - name: Create Release |
| 38 | id: create-release |
| 39 | uses: actions/create-release@v1 |
| 40 | env: |
| 41 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | with: |
| 43 | tag_name: ${{ steps.get-tag.outputs.tag }} |
| 44 | release_name: Release ${{ steps.get-tag.outputs.version }} |
| 45 | draft: false |
| 46 | prerelease: false |
| 47 | |
| 48 | - name: Get matrix |
| 49 | id: get-matrix |
| 50 | run: | |
| 51 | $obj = @{ |
| 52 | languagePack = Get-ChildItem i18n | ForEach-Object Name |
| 53 | } |
| 54 | Write-Host "::set-output name=matrix::$($obj | ConvertTo-Json -Depth 100 -Compress)" |
| 55 | shell: pwsh |
| 56 | |
| 57 | build-publish: |
| 58 | name: 'Build & Publish' |
| 59 | needs: setup-variables |
| 60 | environment: deploy |
| 61 | runs-on: ubuntu-latest |
| 62 | strategy: |
| 63 | matrix: ${{fromJSON(needs.setup-variables.outputs.matrix)}} |
| 64 | steps: |
| 65 | - name: Checkout code |
| 66 | uses: actions/checkout@v2 |
| 67 | with: |
| 68 | ref: ${{ needs.setup-variables.outputs.tag }} |
| 69 | |
| 70 | - name: Generate Name |
| 71 | run: node -e "console.log('PACKAGE_NAME=' + require('./i18n/${{ matrix.languagePack }}/package.json').name + '-v' + require('./i18n/${{ matrix.languagePack }}/package.json').version)" >> $GITHUB_ENV |
| 72 | |
| 73 | - name: Install |
| 74 | run: cd ./i18n/${{ matrix.languagePack }} && npm i |
| 75 | |
| 76 | - name: Build Extension |
| 77 | run: cd ./i18n/${{ matrix.languagePack }} && npx vsce package -o ${{ env.PACKAGE_NAME }}.vsix |
| 78 | |
| 79 | - name: Publish Test Artifact |
| 80 | uses: actions/upload-artifact@v2 |
| 81 | with: |
| 82 | name: ${{ env.PACKAGE_NAME }}.vsix |
| 83 | path: ./i18n/${{ matrix.languagePack }}/${{ env.PACKAGE_NAME }}.vsix |
| 84 | |
| 85 | - name: Verify access to publisher |
| 86 | run: npx vsce verify-pat -p ${{ secrets.MARKETPLACE_PAT }} MS-CEINTL |
| 87 | |
| 88 | - name: Publish Extension |
| 89 | run: npx vsce publish --packagePath ./i18n/${{ matrix.languagePack }}/${{ env.PACKAGE_NAME }}.vsix -p ${{ secrets.MARKETPLACE_PAT }} |
| 90 | |
| 91 | - name: Upload assets to a Release |
| 92 | uses: AButler/upload-release-assets@v2.0 |
| 93 | with: |
| 94 | files: ./i18n/${{ matrix.languagePack }}/${{ env.PACKAGE_NAME }}.vsix |
| 95 | release-tag: ${{ needs.setup-variables.outputs.tag }} |
| 96 | repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 97 | |
| 98 | update-version: |
| 99 | name: Update version |
| 100 | needs: build-publish |
| 101 | runs-on: ubuntu-latest |
| 102 | steps: |
| 103 | - name: Checkout code |
| 104 | uses: actions/checkout@v2 |
| 105 | |
| 106 | - name: Rev patch versions |
| 107 | run: | |
| 108 | Get-ChildItem i18n | ForEach-Object { |
| 109 | cd $_.FullName |
| 110 | npm version patch |
| 111 | } |
| 112 | shell: pwsh |
| 113 | |
| 114 | - name: Expose version |
| 115 | run: node -e "console.log('PACKAGE_VERSION=' + require('./i18n/vscode-language-pack-cs/package.json').version)" >> $GITHUB_ENV |
| 116 | |
| 117 | - name: Create Pull Request on vscode-loc |
| 118 | id: cpr |
| 119 | uses: peter-evans/create-pull-request@v3 |
| 120 | with: |
| 121 | token: ${{ secrets.REPO_PAT }} |
| 122 | title: Rev patch versions to ${{ env.PACKAGE_VERSION }} |
| 123 | body: Automated changes |
| 124 | branch: rev-patch-versions-to-${{ env.PACKAGE_VERSION }} |
| 125 | commit-message: rev patch versions to ${{ env.PACKAGE_VERSION }} |
| 126 | delete-branch: true |
| 127 | |
| 128 | - name: Enable Pull Request Automerge |
| 129 | if: steps.cpr.outputs.pull-request-operation == 'created' |
| 130 | uses: peter-evans/enable-pull-request-automerge@v1 |
| 131 | with: |
| 132 | token: ${{ secrets.REPO_PAT }} |
| 133 | pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} |
| 134 | merge-method: squash |