How to keep version numbers in sync across many files in a project? · community · Discussion #208018 · GitHub
Skip to content
Discussion options

You must be logged in to vote

Hi @blackears 👋

The principle is a single source of truth (as the earlier reply said), but let me make it concrete for your exact setup — version in GitHub Actions workflows + two .cfg files + script files.

1. For GitHub Actions — don't store the version in the workflow at all. Trigger releases from a git tag and read the version from the tag, so the workflow never needs editing per release:

on:
  push:
    tags: ['v*']

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - name: Read version from tag
        run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"

Then reference ${{ env.VERSION }} (or ${{ github.ref_name }}) anywhere a step needs the number. Tag v1.2.3 → version …

Replies: 3 comments

This comment was marked as spam.

This comment was marked as low quality.

Comment options

You must be logged in to vote
0 replies
Answer selected by blackears
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Ask and answer questions about GitHub features and usage Programming Help Discussions around programming languages, open source and software development source:ui Discussions created via Community GitHub templates
4 participants