Staging gets every change. Production should get only what you choose to release. Right now release.yml runs on every push to main, so every change goes straight to production.
A tag names one commit, usually with a version:
git tag
Names the current commit. git tag alone lists the tags.
git tag v1.0.0
git push origin v1.0.0git push alone doesn't send tags: push the tag by name.
A workflow can run on tags instead of branches:
on:
push:
tags: ['v*']'v*' matches every tag that starts with v. In a tag's run, ${{ github.ref_name }} is the tag's name, v1.0.0. Name the image after it, and production's version is readable at a glance:
- run: docker build -t registry.monster.market/shop:${{ github.ref_name }} .In release.yml, change the trigger, and change every ${{ github.sha }} to ${{ github.ref_name }}. Commit and push that, then tag: a tag names the commit you're on, so tag after the commit.
A tag is used once. If a release goes wrong, fix it and release the next version, v1.0.1.
Objectives
- A tag starts the release.
- Name it after the tag.