My use case is I want to have a unique version number for artifacts per each build/run. With current tools like CircleCI, Travis, etc. there is a build number available which is basically a counter that always goes up. So, I can create version strings like 0.1.0-27
. This counter is increased each time even for the same commit.
How can I do something similar with GitHub Actions? Github actions only offer GITHUB_SHA and GITHUB_REF.
Downloading artifacts during a workflow run The actions/download-artifact action can be used to download previously uploaded artifacts during a workflow run. Note: You can only download artifacts in a workflow that were uploaded during the same workflow run.
run_number : A unique number for each run of a particular workflow in a repository. This number begins at 1 for the workflow's first run, and increments with each new run. This number does not change if you re-run the workflow run.
Where does the upload go? At the bottom of the workflow summary page, there is a dedicated section for artifacts.
The GitHub Actions Artifacts API allows you to download, delete, and retrieve information about workflow artifacts. The GitHub Actions Artifacts API allows you to download, delete, and retrieve information about workflow artifacts. Artifacts enable you to share data between jobs in a workflow and store data once that workflow has completed.
Being able to automate release creation and artifact upload with GitHub Actions allows you to fully leverage continuous and automated delivery. To create a release in your repo, your GitHub Actions workflow should utilize the create-release Action. Here is my implementation of it:
GitHub Actions now has a unique number and ID for a run/build in the github context. github.run_id : A unique number for each run within a repository.
All actions and workflows called within a run have write access to that run's artifacts. By default, GitHub stores build logs and artifacts for 90 days, and this retention period can be customized.
GitHub Actions now has a unique number and ID for a run/build in the github
context.
github.run_id : A unique number for each workflow run within a repository. This number does not change if you re-run the workflow run.
github.run_number : A unique number for each run of a particular workflow in a repository. This number begins at 1 for the workflow's first run, and increments with each new run. This number does not change if you re-run the workflow run.
github.run_attempt : A unique number for each attempt of a particular workflow run in a repository. This number begins at 1 for the workflow run's first attempt, and increments with each re-run.
ref: https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context
You can reference them in workflows like this:
- name: Output Run ID run: echo ${{ github.run_id }} - name: Output Run Number run: echo ${{ github.run_number }} - name: Output Run Attempt run: echo ${{ github.run_attempt }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With