Wersjonowanie i automatyzacja wydań
Automatyzuj wersjonowanie semantyczne, tagowanie Git i procesy wydań w Gradle, aby każda kompilacja była identyfikowana w powtarzalny sposób, a wydanie było dostępne jednym poleceniem.
Wersjonowanie i automatyzacja wydań to bezpłatna lekcja Groovy & Gradle: JVM Automation and Build Engineering na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Groovy & Gradle: JVM Automation and Build Engineering, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Groovy & Gradle: JVM Automation and Build Engineering zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
Why Versioning Matters
A clear version on every artifact tells consumers what changed and lets you roll back safely. Manual edits to a version string are error prone, so we automate them.
Setting the Project Version
Every Gradle project has a version property used to name published artifacts.
version = "1.4.0"
group = "com.acme"Semantic Versioning
SemVer uses MAJOR.MINOR.PATCH:
- MAJOR: breaking changes
- MINOR: new backward-compatible features
- PATCH: backward-compatible fixes
SNAPSHOT vs Release
A -SNAPSHOT suffix marks an in-development build that may change. Releases drop the suffix and are immutable once published.
version = "1.5.0-SNAPSHOT"Deriving Version from Git
Many teams compute the version from the latest Git tag so the source of truth is the repository history, not a hard-coded string.
version = providers.exec {
commandLine("git", "describe", "--tags")
}.standardOutput.asText.get().trim()A Release Task
Wrap the steps of a release into a single task that depends on build, tag, and publish.
tasks.register("release") {
dependsOn("build", "publish")
}Tagging in Git
An annotated tag records the released version in history.
git tag -a v1.5.0 -m "Release 1.5.0"
git push origin v1.5.0Bumping the Version
After a release, bump to the next SNAPSHOT so further commits are clearly pre-release. Plugins like Axion or the release plugin automate this.
Reproducible Builds
Pin dependency versions and avoid dynamic ranges so the same source always produces the same artifact, an essential property for trustworthy releases.
implementation("com.google.guava:guava:33.0.0-jre")Wiring into CI
In CI, run the release task only on tagged commits or a protected branch, so accidental pushes never publish.
if [ "$CI_COMMIT_TAG" ]; then gradle release; fiBest Practices
Keep releases predictable:
- One source of truth for the version
- Never republish an existing release version
- Automate tagging and the version bump
Quick Check
Test your understanding of release versioning.
Recap
You learned release automation:
- Use SemVer for MAJOR.MINOR.PATCH
- SNAPSHOT for dev, plain version for releases
- Derive version from Git tags
- Wrap build+tag+publish into a release task gated in CI
Ucz się Groovy dzięki korepetycjom AI — za darmo
Pisz i uruchamiaj kod w przeglądarce, otrzymuj natychmiastową pomoc od korepetytora AI dostępnego 24/7 i kontynuuj naukę w sieci lub w aplikacji.
- Kursy
- 12
- Lekcje
- 48
Często zadawane pytania
Czy lekcja „Wersjonowanie i automatyzacja wydań” jest bezpłatna?
Tak — pełny tekst „Wersjonowanie i automatyzacja wydań” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Groovy & Gradle: JVM Automation and Build Engineering, przejdź na CoddyKit PRO. Kurs Groovy & Gradle: JVM Automation and Build Engineering zawiera 4 lekcji w sumie.
Co nauczysz się w „Wersjonowanie i automatyzacja wydań”?
Automatyzuj wersjonowanie semantyczne, tagowanie Git i procesy wydań w Gradle, aby każda kompilacja była identyfikowana w powtarzalny sposób, a wydanie było dostępne jednym poleceniem. Ćwiczysz Groovy & Gradle: JVM Automation and Build Engineering z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć Groovy & Gradle: JVM Automation and Build Engineering?
Nie wymagamy żadnego doświadczenia. Groovy & Gradle: JVM Automation and Build Engineering w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.
Ile czasu zajmuje lekcja „Wersjonowanie i automatyzacja wydań”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji Groovy & Gradle: JVM Automation and Build Engineering?
Tak. Każda lekcja Groovy & Gradle: JVM Automation and Build Engineering zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Pakowanie JAR, WAR i EAR
- Publikowanie w repozytoriach
- Integracja z CI/CD
- Wersjonowanie i automatyzacja wydań