Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
GitHub Actions Cookbook

You're reading from  GitHub Actions Cookbook

Product type Book
Published in Apr 2024
Publisher Packt
ISBN-13 9781835468944
Pages 250 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Michael Kaufmann Michael Kaufmann
Profile icon Michael Kaufmann

Table of Contents (10) Chapters

Preface 1. Chapter 1: GitHub Actions Workflows 2. Chapter 2: Authoring and Debugging Workflows 3. Chapter 3: Building GitHub Actions 4. Chapter 4: The Workflow Runtime 5. Chapter 5: Automate Tasks in GitHub with GitHub Actions 6. Chapter 6: Build and Validate Your Code 7. Chapter 7: Release Your Software with GitHub Actions 8. Index 9. Other Books You May Enjoy

Versioning your packages

If you now created a new release, the workflow would fail as it would try to publish version 1.0.0 again to the package registry. You would manually have to set the version number in the package.json file. In this recipe, we will use GitVersion to automate this process.

Getting ready

Switch to a new branch:

$ git switch -c add-gitversion

How to do it…

  1. For GitVersion to automatically determine the version of your git workflow, you have to download all references and not just the HEAD branch. We do this by adding the fetch-depth parameter to the checkout action and setting it to 0:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
  2. Set up GitVersion in a specific version:
    - name: Install GitVersion
      uses: gittools/actions/gitversion/setup@v0.10.2
      with:
        versionSpec: '5.x'
  3. Execute GitVersion to determine the version number:
    - name: Determine Version...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}