Every 'tag' build is latest for branch

I’m currently developing a GitLab-based build system. This is working pretty well, but I’m trying to understand how best to control output artefacts.

For example, I don’t want to trigger a build for every commit to master, but instead trigger only when master is tagged.

The issue is that each tag is seen as its own branch, and therefore each tag has a ‘latest’ build. While technically that’s true, it’s not the latest build for the branch, and none of the tagged builds show for master.

There are some obvious questions:

  • Is this “good” way to do this, or is there a “better” way?
  • Do I have to build each commit to master to have it show under the master branch artefacts?

Screenshot:

Important section of .gitlab-ci.yml:

.template: &builder
  stage: build
  script:
    - /makepackage.sh
  only:
    - tags
  artifacts:
    name: "${CI_PROJECT_NAME}_${CI_COMMIT_TAG}_${BRANCH}_${ARCH}"
    paths:
      - "*.pkg.tar.xz"
  cache:
    paths:
      - sources