GithubHelp home page GithubHelp logo

meedamian / github-release Goto Github PK

View Code? Open in Web Editor NEW
65.0 4.0 35.0 55 KB

Github Action to create, update, or add files to Github Releases

License: MIT License

Dockerfile 1.22% Shell 98.78%
github-actions github-releases build-automation

github-release's People

Contributors

meedamian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

github-release's Issues

Allow a environment variable usage in filenames

I would like to be able to use buildNumber environment variable in my asset name

        files: >
          artifacts-${buildNumber}:./artifacts/ArtifactStagingDirectory

or alternatively, allow using TAG (which will be same as buildNumber in my case)

        files: >
          artifacts-${TAG}:./artifacts/ArtifactStagingDirectory

Ignore failure to delete previous release artifacts

Hi,

Neovim uses github-release to create nightly releases:

https://github.com/neovim/neovim/actions/runs/1247880534/workflow#L203-L224

However, it looks like the action fails from time to time with the following error message:

  {
    "message": "Not Found",
    "documentation_url": "https://docs.github.com/rest/reference/repos#delete-a-release-asset"
  }
  curl: (56) OpenSSL SSL_read: Connection reset by peer

As far as I understand, this means that github-release is failing to delete assets of a previous release, here:

# If a list of previously uploaded assets is available, and contains
# item with the same name as currently uploaded, delete it first.
if [ -n "$current_assets" ]; then
asset_id="$(echo "$current_assets" | jq ".\"$file_name\"")"
if [ -n "$asset_id" ]; then
# docs ref: https://developer.github.com/v3/repos/releases/#delete-a-release-asset
gh_release_api "assets/$asset_id" DELETE
fi
fi

This is very odd, as Neovim already takes care of deleting its previous release:

https://github.com/neovim/neovim/actions/runs/1247880534/workflow#L164-L170

So I assume there must be some latency on Github's side that causes github-release to see the previous release (even though it should be deleted) and fail while trying to delete its contents.

If my analysis is right, I think a solution to this problem could be to ignore failure to delete the previous release's artifacts. Does that sound correct to you? If yes, do you want a PR?

'body' variable not passed as string literal

Minor issue, but I'm using the body input (along with files, etc.) to upload a markdown formatted changelog. After Github Actions expands the output from a previous step, jq rejects the input because it tries to parse the string. It would be nice if this entire body was treated as a string literal for such purposes.

Example:

    body: '# Change Log ## [0.4.2](https://github.com/ksync/ksync/tree/0.4.2) (2019-12-06) [Full Changelog](https://github.com/ksync/ksync/compare/0.4.1...0.4.2) **Closed issues:** - Images for release 0.4.0 missing on dockerhub [\#323](https://github.com/ksync/ksync/issues/323) - Ksync copy should copy with default container user [\#296](https://github.com/ksync/ksync/issues/296) **Merged pull requests:** - Switch to using a custom generated changelog [\#328](https://github.com/ksync/ksync/pull/328) ([timfallmk](https://github.com/timfallmk)) - Reformat tags to show version properly. [\#326](https://github.com/ksync/ksync/pull/326) ([timfallmk](https://github.com/timfallmk)) - Syncthing update [\#321](https://github.com/ksync/ksync/pull/321) ([timfallmk](https://github.com/timfallmk)) \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*'
  
    files: bin/ksync_darwin_amd64 bin/ksync_linux_amd64 bin/ksync_windows_amd64.exe bin/radar_darwin_amd64 bin/radar_linux_amd64 bin/radar_windows_amd64.exe
  
    allow_override: false
  env:
    GOROOT: /opt/hostedtoolcache/go/1.13.4/x64
/usr/bin/docker run --name af96b4d7ee21502ef4470890e9e162a481d4cc_4725ca --label af96b4 --workdir /github/workspace --rm -e GOROOT -e INPUT_TOKEN -e INPUT_GZIP -e INPUT_BODY -e INPUT_FILES -e INPUT_TAG -e INPUT_COMMITISH -e INPUT_NAME -e INPUT_DRAFT -e INPUT_PRERELEASE -e INPUT_ALLOW_OVERRIDE -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/ksync/ksync":"/github/workspace" af96b4:d7ee21502ef4470890e9e162a481d4cc
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   129  100   129    0     0   1000      0 --:--:-- --:--:-- --:--:--  1000
jq: invalid JSON text passed to --argjson
Use jq --help for help with command-line options,
or see the jq manpage, or online docs  at https://stedolan.github.io/jq

	ERR: POST to Github release has failed
{
  "message": "Invalid request.\n\nFor 'links/0/schema', nil is not an object.",
  "documentation_url": "https://developer.github.com/v3/repos/releases/#create-a-release"
}
##[error]Docker run failed with exit code 1
  Complete job

Relevant section of workflow yaml:

    - name: Upload assets to release
      uses: meeDamian/[email protected]
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        gzip: false
        body: '${{ steps.changelog.outputs.CHANGELOG }}'
        files: >
          bin/ksync_darwin_amd64
          bin/ksync_linux_amd64
          bin/ksync_windows_amd64.exe
          bin/radar_darwin_amd64
          bin/radar_linux_amd64
          bin/radar_windows_amd64.exe

pass environment variables as file

I am using the same action for different files. In order to not repeat myself too much, I use environmental variables. Hoever it seems that we can no use env variables in the files section.

  env:
    FILE: data/.test.csv
    ...
      - uses: meeDamian/[email protected]
        name: upload file
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          allow_override: true
          files: ${{ env.FILE }}
          gzip: false
          tag: 0.0.1

results in:

 Files to be uploaded to Github:
  {
    "message": "Not Found",
    "documentation_url": "https://docs.github.com/rest/reference/repos#delete-a-release-asset"
  }
  stat: can't stat '/github/home/assets/*': No such file or directory
  curl: Can't open '/github/home/assets/*'!
  curl: try 'curl --help' or 'curl --manual' for more information
  curl: (26) Failed to open/read local data from file/application

Body fails when it contains double quotes.

Like #10 (comment), probably need to replace " with \". The sed filter could probably be moved inline to toJsonOrNull to make sure it covers other fields (really just release name).

I know this action is semi-deprecated but I am also stuck on this until the GitHub provided one handles some of the same use cases as your fantastic action.

I'll try to open a PR to fix this but I've worked around it on my end already so unless it comes up again, I may forget, so I thought I'd document it in an issue for the time being.

Intermitten SSL issues

I have no idea why but I get frequent-but-intermittent SSL failures like following:

Create Release
Upload Assets
  Files to be uploaded to Github:
  devserver.js
  curl: (55) OpenSSL SSL_write: Connection reset by peer, errno 104

Unable to override assets on existing release

Same issue as #2

        - name: Upload assets to release
          uses: meeDamian/[email protected]
          with:
            token: ${{ secrets.GITHUB_TOKEN }}
            tag: latest
            name: latest
            allow_override: true
            gzip: false
            files: >
                filename1.ext
                filename2.ext
Create Release
Upload Assets
  Files to be uploaded to Github:
  filename1.ext
  filename2.ext
  {
    "message": "Not Found",
    "documentation_url": "https://docs.github.com/rest/reference/repos#delete-a-release-asset"
  }
  Error: failed to upload asset: filename1.ext (see log for details)
  
  	ERR: Failed asset upload: filename1.ext
  {
    "message": "Validation Failed",
    "request_id": "07C0:4CCE:385984:52E5BB:6120476B",
    "documentation_url": "https://docs.github.com/rest",
    "errors": [
      {
        "resource": "ReleaseAsset",
        "code": "already_exists",
        "field": "name"
      }
    ]
  }

I also tried with uses: meeDamian/[email protected]; however that fails to find the version.

Error: Unable to resolve action `meeDamian/[email protected]`, unable to find version `2.0.3`

[Feature] upadate body from path

Currently supports body parameter that takes starting. It would be helpful if there is another parameter body_path that takes file (txt or md) and puts in body

Cleanup

  • Nuke commits
  • Write proper README
  • Delete all random tags
  • Delete workflows
  • Publish to marketplace

Do globs work in `files`?

Hi!

Thanks for the project, really appreciate it.

Just wondering if globs work in files? for example will the following:

jobs:
  build:
  ...
    steps:
    ...
    - uses: meeDamian/[email protected]
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        gzip: false
        allow_override: true
        files: build/*.txt

expand to upload every *.txt file under the build/ directory individually?

I've tried look through the source code, but my bash isn't as good as I thought. There's one comment that implies globbing does happen, but some small tests just in my shell make it seem like they don't work.

I think the following is the same as the source, but it doesn't glob, and echos calendars/*.ics

glob=build/*.txt
for filename in "$glob"; do
    echo $filename
done

However this example (which isn't the same) globs as expected:

for filename in build/*.txt; do
    echo $filename
done

If you can confirm what exactly the expected behaviour is, I'm happy to make a PR to add this feature!

Thanks!

Parameter to keep X oldest releases and delete the rest

We create a bunch of releases (temp dev versions) of our open source software, OpenRefine.
See for example: https://github.com/OpenRefine/OpenRefine-nightly-releases/releases

It would be nice to use your action with a new parameter where I specify keep:3 to keep the 3 latest releases and it then deletes all the older releases.

Any chance you could add that option?
Or a brand new action called delete-older-releases ?
I looked around and didn't find something that would work. But pointers welcome.

allow_override flag does not work for assets

Updating the release fails when asset is beeing updated:

    - uses: meeDamian/[email protected]
      with:
        token: ${{github.token}}
        commitish: ${{github.sha}}
        tag: latest
        name: Latest draft
        prerelease: true
        gzip: false
        files: >
          file.pdf:paper/paper.pdf
        allow_override: true
ERR: Uploading file.pdf to Github release has failed
{
  "message": "Validation Failed",
  "request_id": "07C0:5BBF:F7389:15503D:5D7E3EF4",
  "documentation_url": "https://developer.github.com/v3",
  "errors": [
    {
      "resource": "ReleaseAsset",
      "code": "already_exists",
      "field": "name"
    }
  ]
}

After manually removing the asset it seems that tag and commitsh was also not updated.

Allow variable usage for tag

I want to provide a tag number via environment variable set in earlier steps; however, it treats it as a string.

tag: $buildNumber

then I came up with the workaround below

tag: buildNumber

(I'm sorry, my shell scripting is not good enough, so I came up with something like this in here)

if [ ! -z "${TAG}" ]; then
  if TAGFROMENVVAR=$(printenv ${TAG}); then
    if [ ! -z "$TAGFROMENVVAR" ]; then
      TAG="${TAGFROMENVVAR}"
    fi
  fi
fi

it checks if the given name exists in an environment variable or not.

Support cross platform

I have windows and macOS specific builds and this action only support linux

Can you introduce cross platform support?

Spaces in file names cases upload step to not work.

Spaces in file names cases upload step to not work.

Config like this

      - name: Release files - Ubuntu
        if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest'
        uses: meeDamian/[email protected]
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          gzip: false
          files: >
            dist_electron/*.AppImage
            dist_electron/*.snap
            dist_electron/latest*.yml

With files like this


  total 261284
-rwxr-xr-x 1 runner docker 144196185 Mar 22 15:10 Product Name-2022.2.22.AppImage
-rw-r--r-- 1 runner docker       785 Mar 22 15:11 builder-debug.yml
-rw-r--r-- 1 runner docker       388 Mar 22 15:11 latest-linux.yml
drwxr-xr-x 5 runner docker      4096 Mar 22 15:09 linux-unpacked
-rw-r--r-- 1 runner docker 123338752 Mar 22 15:11 template-electron-vuex-vuetify_2022.2.22_amd64.snap

Generate error like this

Upload Assets
  tar: dist_electron/Product: No such file or directory
  tar: error exit delayed from previous errors

Fail to run under windows

2020-12-08T12:13:56.9429791Z ##[group]Run meeDamian/[email protected]
2020-12-08T12:13:56.9430318Z with:
2020-12-08T12:13:56.9430638Z tag: continuous
2020-12-08T12:13:56.9431039Z name: Continuous release
2020-12-08T12:13:56.9431726Z body: Continuous build for development and test
2020-12-08T12:13:56.9432185Z allow_override: true
2020-12-08T12:13:56.9433792Z token: ***
2020-12-08T12:13:56.9434105Z files: deploy
2020-12-08T12:13:56.9434410Z gzip: true
2020-12-08T12:13:56.9434672Z env:
2020-12-08T12:13:56.9435139Z pythonLocation: C:\hostedtoolcache\windows\Python\3.9.0\x64
2020-12-08T12:13:56.9435718Z Qt5_Dir: D:/a/ping-components/Qt/5.15.1/msvc2019_64
2020-12-08T12:13:56.9436292Z QT_PLUGIN_PATH: D:/a/ping-components/Qt/5.15.1/msvc2019_64/plugins
2020-12-08T12:13:56.9436888Z QML2_IMPORT_PATH: D:/a/ping-components/Qt/5.15.1/msvc2019_64/qml
2020-12-08T12:13:56.9437355Z ##[endgroup]
2020-12-08T12:13:56.9582820Z ##[error]Container action is only supported on Linux

Add support for regular zip

As you may see in attachment, GitHub provides both formats zip and tar.gz.
Please add support for regular zip

image

Use workflow name as default release name

Instead of using the Branch name, using the Workflow name as default name would be more useful

RELEASE_NAME="${INPUT_NAME}"
if [ -z "${RELEASE_NAME}" ]; then
  RELEASE_NAME="${GITHUB_WORKFLOW}"
fi
  --argjson name              "$(toJsonOrNull "${RELEASE_NAME}")"       \

Add extra option to the compression options

Hi Damian,

Great work extending the github-release action.

I would like to make a suggestion regarding handling folders.

gzip: true
files: > 
VxFormGenerator.Components.Plain:VxFormGenerator.Components.Plain/bin/Release/ 
VxFormGenerator.Core:VxFormGenerator.Core/bin/Release/
VxFormGenerator.Components.Bootstrap:VxFormGenerator.Components.Bootstrap/bin/Release/

This will result in a .tgz file. containing: VxFormGenerator.Core.tgz\VxFormGenerator.Core.tar\VxFormGenerator.Core\bin\Release\*.*

Why not add an extra option flatZip that does the following: zip the content found in the folder: VxFormGenerator.Core\bin\Release\.

This would result in a VxFormGenerator.Core.zip containing only the data found at the Release folder.

How does this sound to you?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.