actions / upload-release-asset

An Action to upload a release asset via the GitHub Release API
MIT License
688 stars 190 forks source link

browser_download_url not populating on windows-latest #49

Open datdamnzotz opened 4 years ago

datdamnzotz commented 4 years ago

name: Push Build
# For releases
on:
  push:
    # Sequence of patterns matched against refs/tags
    tags:
    - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
  build:
    name: Build
    runs-on: windows-latest
    steps:
      - name: Get Version
        id: get_version
        run: |
          echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
          echo ::set-output name=VERSION2::${GITHUB_REF#refs/tags/v}
        shell: bash
      - name: Checkout
        uses: actions/checkout@v2
      - name: Zip project # This would actually build your project, using zip for an example artifact
        run: 7z.exe a -tzip ${{ steps.get_version.outputs.VERSION }}.zip . -mx0 -xr!.git -xr!.github
        shell: cmd
      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          draft: false
          prerelease: false
      - name: Upload Release Assets
        id: upload-release-asset 
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 
          asset_path: ./${{ steps.get_version.outputs.VERSION }}.zip
          asset_name: ${{ steps.get_version.outputs.VERSION }}.zip
          asset_content_type: application/zip
      - name: Update module.json
        run: |
          echo ${{ steps.get_version.outputs.VERSION2 }}
          echo ${{ steps.upload-release-asset.browser_download_url }}
          sed -i '/"version":/c\  "version": "${{ steps.get_version.outputs.VERSION2 }}",' module.json
          sed -i '/"download":/c\  "download": "${{ steps.upload-release-asset.browser_download_url }}"' module.json
          type module.json
        shell: cmd
      - name: Push module.json back to Github
        uses: actions-x/commit@v1
        with:
          name: GitHub Actions Autocommitter
          branch: master
          files: ./module.json
          token: ${{ secrets.MY_SECRET_TOKEN }}

Screen shot image