Skip to main content

Use GitHub Actions to send a tweet when you make a new release

Project description

How to tweet your releases

Send a tweet to let people know when you release software on GitHub.

It's great to release software. And even better when people actually know about it!

One way to let people know about your new software releases is to tell them on Twitter. But we're software developers, not social media managers -- so that means we automate all the things.

With tweetrel, you can have GitHub send a tweet for you whenever you make a release.

Install

pip install tweetrel

How to use

First, you need to add your Twitter API details as GitHub secrets. You'll need to sign up for a Twitter API account if you don't already have one. Once you've signed up, Twitter will give you four keys: consumer_key, consumer_secret, access_token, and access_token_secret. Create a new secret called TWITTER, and paste those four keys in, with a space between each one.

If you need to send Tweets on behalf of a different user to the one attached to your login, you'll need to authenticate with Twitter as that user. Run tweetrel-auth in your terminal and follow the instructions, and it will give you the access_token and access_token_secret you need -- paste them (after a space) after your consumer_key and consumer_secret and that will let you send tweets as the user you authenticated as.

Next, in your terminal, cd to the root of your repo, and then run:

tweetrel-install

That will set tweetrel up for you to run automatically upon release. You'll see two folders added to your .github folder, containing the YAML workflow and python script. No additional setup is needed, other than pushing these to GitHub:

git add -A .github
git commit -am 'Add tweetrel`
git push

You can test this without actually making a release by going to your GitHub repo in your browser, clicking the Actions tab, then clicking on the tweet action, and clicking the run workflow button. That will use GitHub's example release payload for testing.

Once you've confirmed it's working, try making a release on GitHub, and check that you see the green tick in the Actions tab showing a successful run of the tweet action.

Customization

As you'll see, the default template is:

New #{repo} release: v{tag_name}. {html_url}\n\n{body}

You can customize that by setting the TWEETREL_TEMPLATE environment variable. For instance, add this (with suitable indentation) to the env: section of your workflow YAML file:

TWEETREL_TEMPLATE: |
  We are proud to announce the {tag_name} release of {repo}.

  For more, see: {html_url}. Here are the details:
  {body}

The | is the YAML character that indicates a multiline string. The sections in {...} are the Python formatting template variables that will be replaced by the details of your release. You don't need to include all of them if you don't want them.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tweetrel-0.0.5.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

tweetrel-0.0.5-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file tweetrel-0.0.5.tar.gz.

File metadata

  • Download URL: tweetrel-0.0.5.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.0 setuptools/49.6.0.post20200925 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.7

File hashes

Hashes for tweetrel-0.0.5.tar.gz
Algorithm Hash digest
SHA256 386d886400b10a2866fb783138a37eb4adf74d579bfc763c0ef0bc8efb10d882
MD5 d89863bf7ed897d2308b77e569dc7828
BLAKE2b-256 2c256b5e665c62c72eff56b499a1440629fb2bd9824b1feb0edcc82aadde53cf

See more details on using hashes here.

File details

Details for the file tweetrel-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: tweetrel-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.0 setuptools/49.6.0.post20200925 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.7

File hashes

Hashes for tweetrel-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e996b263e2a525fd4918aa17a46c17c3217c00545a2a9d5e6b8cfbbf45e5f475
MD5 bf5d51ebf5d3eec94f8d8a3bbbf0b269
BLAKE2b-256 2fb81c8821e4982401336d2f86b66189d6c0085c7499fa1f578ac7fbf449b03b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page