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

ci: setup ci to upload binaries to github for convenience by our team #3

Merged
merged 6 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/deploy-binary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Deploy a binary for team to use

on:
push:
branches: [main]

# Workflow to compile a binary of the script and upload it to a github release. This allows team members to download the binary and run it on their
# development machines without needing to install deno or any other language.
#
# Deployment strategy for this project is to only maintain a "latest" release version. Why?
# 1. This tool is currently used internally by our team and therefore, no need to maintain multiple versions.
# 2. Deno compiled binary files can be larger in size, no use keeping files in the repo that will probably not be used.
jobs:
update-latest-binary:
runs-on: ubuntu-latest
permissions:
contents: write # to be able to push git tags and create github releases
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Compile script into a macOS m1 binary
run: |
deno compile --allow-all --target aarch64-apple-darwin binny.ts
mv binny binny-macos-m1

- name: Compile script into a Linux binary
run: |
deno compile --allow-all --target x86_64-unknown-linux-gnu binny.ts
mv binny binny-linux-x86_64

- name: Create a git tag 'latest' and a GitHub release 'latest' to attach compiled binary to.
uses: ncipollo/release-action@v1
with:
artifacts: "binny-macos-m1,binny-linux-x86_64" # upload these binary files to the release so team members can easily download it.
tag: "latest" # create a git tag 'latest'
commit: "main" # create a git tag 'latest' from the latest commit on the main branch
allowUpdates: true # if 'latest' release already exists, update it.
artifactErrorsFailBuild: true # fail the github action if there is an error trying to upload artifacts. The main point of this github release is to upload the binary, so if that fails, we should fail the build.
body: "Compiled binary files are attached for convenient download and executing in your development machine and CI server" # body of the github release.
makeLatest: true # make this release the latest release.
replacesArtifacts: true # replace the artifacts in the existing github release, if any exists.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# don't commit the built binary
binny
binny
binny-*