microsoft/vscode-loc
Publicmirrored fromhttps://github.com/microsoft/vscode-locAvailable
.github/workflows/release.yml
195lines · modecode
| 1 | on: |
| 2 | schedule: |
| 3 | # Run every Wednesday |
| 4 | - cron: 0 0 * * WED |
| 5 | workflow_dispatch: |
| 6 | inputs: |
| 7 | create-release: |
| 8 | required: false |
| 9 | type: boolean |
| 10 | description: If true, this run will tag and create a GitHub Release. Defaults to false. |
| 11 | extension: |
| 12 | required: false |
| 13 | type: string |
| 14 | description: The specific extension to publish |
| 15 | |
| 16 | name: Release |
| 17 | |
| 18 | jobs: |
| 19 | setup-variables: |
| 20 | name: Setup variables |
| 21 | runs-on: ubuntu-latest |
| 22 | outputs: |
| 23 | tag: ${{ steps.get-tag.outputs.tag }} |
| 24 | version: ${{ steps.get-tag.outputs.version }} |
| 25 | matrix: ${{ steps.get-matrix.outputs.matrix }} |
| 26 | release_upload_url: ${{ steps.create-release.outputs.upload_url }} |
| 27 | steps: |
| 28 | - name: Print inputs |
| 29 | shell: pwsh |
| 30 | run: | |
| 31 | "Inputs" |
| 32 | "create-release: ${{ github.event.inputs.create-release }}" |
| 33 | "extension: ${{ github.event.inputs.extension }}" |
| 34 | |
| 35 | - name: Checkout code |
| 36 | uses: actions/checkout@v2 |
| 37 | |
| 38 | - name: Get tag |
| 39 | id: get-tag |
| 40 | run: | |
| 41 | $version = (Get-Content ./i18n/vscode-language-pack-cs/package.json -Raw | ConvertFrom-Json).version |
| 42 | Write-Host "tag: release/$version" |
| 43 | Write-Host "::set-output name=tag::release/$version" |
| 44 | Write-Host "::set-output name=version::$version" |
| 45 | shell: pwsh |
| 46 | |
| 47 | - name: Commit tagger |
| 48 | if: ${{ github.event.inputs.create-release != 'false' }} |
| 49 | uses: tvdias/github-tagger@v0.0.2 |
| 50 | with: |
| 51 | repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 52 | tag: ${{ steps.get-tag.outputs.tag }} |
| 53 | |
| 54 | - name: Create Release |
| 55 | if: ${{ github.event.inputs.create-release != 'false' }} |
| 56 | id: create-release |
| 57 | uses: actions/create-release@v1 |
| 58 | env: |
| 59 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 60 | with: |
| 61 | tag_name: ${{ steps.get-tag.outputs.tag }} |
| 62 | release_name: Release ${{ steps.get-tag.outputs.version }} |
| 63 | draft: false |
| 64 | prerelease: false |
| 65 | |
| 66 | - name: Get full matrix |
| 67 | id: get-matrix |
| 68 | run: | |
| 69 | $specifiedExtension = '${{ github.event.inputs.extension }}' |
| 70 | $obj = if ($specifiedExtension) { |
| 71 | if (!(Test-Path "i18n/$specifiedExtension")) { |
| 72 | throw "specified extension not found" |
| 73 | } |
| 74 | @{ |
| 75 | languagePack = @($specifiedExtension) |
| 76 | } |
| 77 | } else { |
| 78 | @{ |
| 79 | languagePack = Get-ChildItem i18n | ForEach-Object Name |
| 80 | } |
| 81 | } |
| 82 | Write-Host "::set-output name=matrix::$($obj | ConvertTo-Json -Depth 100 -Compress)" |
| 83 | shell: pwsh |
| 84 | |
| 85 | build-publish: |
| 86 | name: 'Build & Publish' |
| 87 | needs: setup-variables |
| 88 | environment: deploy |
| 89 | runs-on: ubuntu-latest |
| 90 | strategy: |
| 91 | matrix: ${{fromJSON(needs.setup-variables.outputs.matrix)}} |
| 92 | steps: |
| 93 | - name: Checkout code |
| 94 | uses: actions/checkout@v2 |
| 95 | with: |
| 96 | ref: ${{ needs.setup-variables.outputs.tag }} |
| 97 | |
| 98 | - name: Generate Name |
| 99 | run: node -e "console.log('PACKAGE_NAME=' + require('./i18n/${{ matrix.languagePack }}/package.json').name + '-v' + require('./i18n/${{ matrix.languagePack }}/package.json').version)" >> $GITHUB_ENV |
| 100 | |
| 101 | - name: Install |
| 102 | run: cd ./i18n/${{ matrix.languagePack }} && npm i |
| 103 | |
| 104 | - name: Build Extension |
| 105 | run: cd ./i18n/${{ matrix.languagePack }} && npx vsce package -o ${{ env.PACKAGE_NAME }}.vsix |
| 106 | |
| 107 | - name: Publish Test Artifact |
| 108 | uses: actions/upload-artifact@v2 |
| 109 | with: |
| 110 | name: ${{ env.PACKAGE_NAME }}.vsix |
| 111 | path: ./i18n/${{ matrix.languagePack }}/${{ env.PACKAGE_NAME }}.vsix |
| 112 | |
| 113 | - name: Verify access to publisher |
| 114 | run: | |
| 115 | RETRY_NUM=3 |
| 116 | RETRY_EVERY=10 |
| 117 | |
| 118 | NUM=$RETRY_NUM |
| 119 | until npx vsce verify-pat -p ${{ secrets.MARKETPLACE_PAT }} MS-CEINTL |
| 120 | do |
| 121 | 1>&2 echo failure ... retrying $NUM more times |
| 122 | sleep $RETRY_EVERY |
| 123 | ((NUM--)) |
| 124 | |
| 125 | if [ $NUM -eq 0 ] |
| 126 | then |
| 127 | 1>&2 echo command was not successful after $RETRY_NUM tries |
| 128 | exit 1 |
| 129 | fi |
| 130 | done |
| 131 | |
| 132 | echo success! |
| 133 | |
| 134 | - name: Publish Extension |
| 135 | run: npx vsce publish --packagePath ./i18n/${{ matrix.languagePack }}/${{ env.PACKAGE_NAME }}.vsix -p ${{ secrets.MARKETPLACE_PAT }} |
| 136 | |
| 137 | - name: Upload assets to a Release |
| 138 | uses: AButler/upload-release-assets@v2.0 |
| 139 | with: |
| 140 | files: ./i18n/${{ matrix.languagePack }}/${{ env.PACKAGE_NAME }}.vsix |
| 141 | release-tag: ${{ needs.setup-variables.outputs.tag }} |
| 142 | repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 143 | |
| 144 | update-version: |
| 145 | name: Update version |
| 146 | needs: build-publish |
| 147 | runs-on: ubuntu-latest |
| 148 | steps: |
| 149 | - name: Checkout code |
| 150 | uses: actions/checkout@v2 |
| 151 | |
| 152 | - name: Rev patch versions on all |
| 153 | if: ${{ github.event.inputs.extension == '' }} |
| 154 | run: | |
| 155 | Get-ChildItem i18n | ForEach-Object { |
| 156 | cd $_.FullName |
| 157 | npm version patch |
| 158 | } |
| 159 | shell: pwsh |
| 160 | |
| 161 | - name: Expose version for all |
| 162 | if: ${{ github.event.inputs.extension == '' }} |
| 163 | run: node -e "console.log('PACKAGE_VERSION=' + require('./i18n/vscode-language-pack-cs/package.json').version)" >> $GITHUB_ENV |
| 164 | |
| 165 | - name: Rev patch versions on specified extension |
| 166 | if: ${{ github.event.inputs.extension != '' }} |
| 167 | run: | |
| 168 | Get-ChildItem i18n | Where-Object Name -eq '${{ github.event.inputs.extension }}' | ForEach-Object { |
| 169 | cd $_.FullName |
| 170 | npm version patch |
| 171 | } |
| 172 | shell: pwsh |
| 173 | |
| 174 | - name: Expose version for specified extension |
| 175 | if: ${{ github.event.inputs.extension != '' }} |
| 176 | run: node -e "console.log('PACKAGE_VERSION=' + require('./i18n/${{ github.event.inputs.extension }}/package.json').version)" >> $GITHUB_ENV |
| 177 | |
| 178 | - name: Create Pull Request on vscode-loc |
| 179 | id: cpr |
| 180 | uses: peter-evans/create-pull-request@v3 |
| 181 | with: |
| 182 | token: ${{ secrets.REPO_PAT }} |
| 183 | title: ${{ github.event.inputs.extension }}Rev patch versions to ${{ env.PACKAGE_VERSION }} |
| 184 | body: Automated changes |
| 185 | branch: ${{ github.event.inputs.extension }}rev-patch-versions-to-${{ env.PACKAGE_VERSION }} |
| 186 | commit-message: rev patch versions to ${{ env.PACKAGE_VERSION }} |
| 187 | delete-branch: true |
| 188 | |
| 189 | - name: Enable Pull Request Automerge |
| 190 | if: steps.cpr.outputs.pull-request-operation == 'created' |
| 191 | uses: peter-evans/enable-pull-request-automerge@v1 |
| 192 | with: |
| 193 | token: ${{ secrets.REPO_PAT }} |
| 194 | pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} |
| 195 | merge-method: squash |
| 196 | |