release #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
jobs: # these jobs run serially because of the 'needs:' keyword on each | |
ci: # kick off a different workflow | |
uses: ./.github/workflows/ci.yml | |
with: | |
fail: ${{ inputs.fail }} | |
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 }} | |
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 | |
run: | | |
echo "the ORIGINAL sha: `git rev-parse HEAD`" | |
echo ${{ github.run_id }} > 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}} | |
}) | |
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/" |