Skip to content

release

release #30

Workflow file for this run

name: release
on:
workflow_dispatch:
inputs:
release:
description: 'is this an actual release?'
required: true
type: boolean
default: false
fail:
description: 'should a job fail?'
required: true
type: boolean
default: false
release-version:
required: true
type: string
new-version:
required: true
type: string
jobs: # these jobs run serially because of the 'needs:' keyword on each
ci: # kick off a different workflow - all the normal CI stuff can be neatly isolated
uses: ./.github/workflows/ci.yml
with:
fail: ${{ inputs.fail }}
# could add a 'capture-assets' boolean input option on CI so that it knows if/when to store artifacts for subsequent packaging
# The normal CI run won't need to store those artifacts - only when it's being run as a 'sub'-workflow of 'release'
package: # shows retrieving an artifact from the previous step
runs-on: ubuntu-latest
needs: ci # wait for the ci job to complete
steps:
- name: step1
run: echo "building some packages"
- name: Download a single artifact
uses: actions/download-artifact@v4
with:
name: my-artifact
- name: ls
run: ls
tag: # shows how to add a tag to the git repo
runs-on: ubuntu-latest
needs: package # wait for package job to complete
# only execute if this is a release
if: ${{ inputs.release }}
outputs:
new-sha: ${{ steps.update-version.outputs.new-sha }} # used by the final-tag job
steps:
- name: checkout
uses: actions/checkout@v4
- name: output
run: |
echo "the current sha: $GITHUB_SHA"
- name: Create/update tag
uses: actions/github-script@v7
with:
# instead of the default GITHUB_TOKEN, this could be a separate token that only gives permission to add tags
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/release-run-${{ github.run_id }}',
sha: context.sha
})
- name: update the version file
id: update-version # need an 'id' here so we can grab the new-sha and store it as an output
# it's not really a 'version', but it's a value that changes with each run
run: |
echo "the ORIGINAL sha: `git rev-parse HEAD`"
echo ${{ github.run_id }} > version.txt
echo VERSION=${{ inputs.new-version }} >> version.txt
git config --global user.name "the 'release' github action"
git config --global user.email "[email protected]"
git add version.txt
git commit -m 'update version'
git push
echo "the NEW sha: `git rev-parse HEAD`"
echo "new-sha=`git rev-parse HEAD`" >> "$GITHUB_OUTPUT"
final-tag:
runs-on: ubuntu-latest
needs: tag
steps:
- name: Create/update tag 2
uses: actions/github-script@v7
with:
# instead of the default GITHUB_TOKEN, this could be a separate token that only gives permission to add tags
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/release-run-${{ github.run_id }}-POST',
sha: '${{needs.tag.outputs.new-sha}}' # the single quotes are important!!!!
})
push:
runs-on: ubuntu-latest
needs: package
steps:
- name: push to release
if: ${{ inputs.release }}
run: echo "this is where we'd push to the release repo"
- name: push to dev
if: ${{ !inputs.release }}
run: echo "this is where we'd push to the dev repo"
- name: validate packages
run: echo "validate whatever we find in packages/"