Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Actions workflow for creating packages for releases #51

Closed
simonw opened this issue Sep 3, 2021 · 9 comments
Closed

GitHub Actions workflow for creating packages for releases #51

simonw opened this issue Sep 3, 2021 · 9 comments
Labels
ci packaging Anything involving making stuff installable

Comments

@simonw
Copy link
Owner

simonw commented Sep 3, 2021

Follows #20 and #50 - when I create a release in this GitHub repo it should attach the resulting .zip file to the release.

@simonw simonw added ci packaging Anything involving making stuff installable labels Sep 3, 2021
@simonw simonw added this to the First public installer release milestone Sep 3, 2021
@simonw
Copy link
Owner Author

simonw commented Sep 8, 2021

I'm going to call this release.yml.

It will be very similar to test.yml - https://github.com/simonw/datasette-app/blob/5c3c0ab193f779856a53d68f2c0934575a733de4/.github/workflows/test.yml - but will be triggered by a release and will attach something to the release instead of publishing an artifact.

@simonw
Copy link
Owner Author

simonw commented Sep 8, 2021

Weird that GitHub have archived their official action for this: https://github.com/actions/upload-release-asset

@simonw
Copy link
Owner Author

simonw commented Sep 8, 2021

@simonw
Copy link
Owner Author

simonw commented Sep 8, 2021

I'm going to figure this out in my https://github.com/simonw/playing-with-actions repo.

@simonw
Copy link
Owner Author

simonw commented Sep 8, 2021

After a few iterations I managed to ship https://github.com/simonw/playing-with-actions/releases/tag/v4 using the code from https://github.com/simonw/playing-with-actions/blob/v4/.github/workflows/release.yml - in particular this script block:

    - uses: actions/github-script@v4
      name: Upload release attachment
      with:
        script: |
          const fs = require('fs');
          const tag = context.ref.replace("refs/tags/", "");
          console.log("tag = ", tag);
          // Get release for this tag
          const release = await github.repos.getReleaseByTag({
            owner: context.repo.owner,
            repo: context.repo.repo,
            tag
          });
          console.log("release = ", release);
          // Upload the release asset
          await github.repos.uploadReleaseAsset({
            owner: context.repo.owner,
            repo: context.repo.repo,
            release_id: release.data.id,
            name: "My.zip",
            data: await fs.readFileSync("My.zip")
          });

simonw added a commit that referenced this issue Sep 8, 2021
@simonw
Copy link
Owner Author

simonw commented Sep 8, 2021

@simonw simonw closed this as completed Sep 8, 2021
@simonw
Copy link
Owner Author

simonw commented Sep 8, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci packaging Anything involving making stuff installable
Projects
None yet
Development

No branches or pull requests

1 participant