Skip to content

Instantly share code, notes, and snippets.

Last active January 10, 2023 20:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
GitHub Actions to tag a repo at the beginning of each week. See
# Apply a tag to HEAD at the beginning of each week.
# We can use this to create semver-looking tags for releases like
# 2020.44.123+abc1234
# Mondays at 5am UTC / midnight EST
- cron: '0 5 * * 1'
runs-on: ubuntu-latest
- name: tag HEAD with date +%G.%V
run: |
curl --request POST \
--url${{ github.repository }}/git/refs \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--data @- << EOF
"ref": "refs/tags/$(date +%G.%V)",
"sha": "${{ github.sha }}"
Copy link

wisnij commented Jan 10, 2023

Should the date format maybe be %G.%V, so both the year and week components will indicate the ISO week? Otherwise you could get non-monotonic tags around the start of the year:

$ for d in 2022-12-31 2023-01-01 2023-01-02; do date -d $d +'%F  %Y.%V  %G.%V'; done
2022-12-31  2022.52  2022.52
2023-01-01  2023.52  2022.52
2023-01-02  2023.01  2023.01

Copy link

Ha, given that it's the second week of January I'm guessing that's not a theoretical question - thanks!

Copy link

FWIW, in a repo I'm using this GH Actions recipe on, I didn't see a bug this year when it produced tags. Maybe the LC_LOCALE is different from yours or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment