|
| 1 | +name: Zip and release |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + version: |
| 6 | + description: 'version' |
| 7 | + required: true |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: Zip and release |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Install dependencies |
| 15 | + run: sudo apt-get --no-install-recommends -yq install xmlstarlet |
| 16 | + |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@v2 |
| 19 | + |
| 20 | + - name: Zip plugin and update repo.xml |
| 21 | + run: | |
| 22 | + xmlstarlet ed --inplace --update "//extension/version" --value "${{ github.event.inputs.version }}" install.xml |
| 23 | + zip -r ${{ github.event.repository.name }}-${{ github.event.inputs.version }}.zip . -x ".git/*" ".github/*" "repo.xml" |
| 24 | + export SHA1SUM=`sha1sum "${{ github.event.repository.name }}-${{ github.event.inputs.version }}.zip" | awk '{ print $1 }'` |
| 25 | + export ZIP_URL="https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.version }}/${{ github.event.repository.name }}-${{ github.event.inputs.version }}.zip" |
| 26 | + xmlstarlet ed --inplace --update "//extensions/plugins/plugin/sha" --value "$SHA1SUM" repo.xml |
| 27 | + xmlstarlet ed --inplace --update "//extensions/plugins/plugin/url" --value "$ZIP_URL" repo.xml |
| 28 | + xmlstarlet ed --inplace --update "//extensions/plugins/plugin/@version" --value "${{ github.event.inputs.version }}" repo.xml |
| 29 | + |
| 30 | + - name: Commit changes |
| 31 | + run: | |
| 32 | + git config user.name github-actions |
| 33 | + git config user.email github-actions@github.com |
| 34 | + git commit -a -m "Release ${{ github.event.inputs.version }}" |
| 35 | + git push |
| 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: ${{ github.event.inputs.version }} |
| 44 | + release_name: Release ${{ github.event.inputs.version }} |
| 45 | + draft: false |
| 46 | + prerelease: false |
| 47 | + |
| 48 | + - name: Upload Release Asset |
| 49 | + id: upload-release-asset |
| 50 | + uses: actions/upload-release-asset@v1 |
| 51 | + env: |
| 52 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + with: |
| 54 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 55 | + asset_path: ./${{ github.event.repository.name }}-${{ github.event.inputs.version }}.zip |
| 56 | + asset_name: ${{ github.event.repository.name }}-${{ github.event.inputs.version }}.zip |
| 57 | + asset_content_type: application/zip |
0 commit comments