docs: add notes on containers #211
Workflow file for this run
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
--- | |
# Update versions and create release PR | |
# Source: https://www.thisdot.co/blog/tag-and-release-your-project-with-github-actions-workflows | |
# https://goreleaser.com/ci/actions/#tag-fetching | |
# | |
# - Manually triggered "release-prepare.yml" workflow will create a PR | |
# - This PR will do some minor tweaks to ready for release (such as increment the version across files) | |
# - Upon merging the PR, "release" job defined here will trigger, which will: | |
# - create a tag | |
# - do the actual release with goreleaser | |
name: release | |
on: | |
pull_request: | |
types: | |
- closed | |
permissions: | |
contents: read | |
jobs: | |
release-golang: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # To create a new release | |
if: startsWith(github.event.pull_request.title, 'Release:') && github.event.pull_request.merged == true | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: stable | |
- name: Set up Git | |
run: | | |
git config user.name "Release bot" | |
git config user.email "[email protected]" | |
- name: Get current version | |
id: get_version | |
run: | | |
git branch --show-current | |
git pull | |
echo "version=$(grep 'const firmwareActionVersion' < action/main.go | sed -E 's/.*= "//g' | sed 's/"//g')" >> "${GITHUB_OUTPUT}" | |
# Can't really use cocogitto here | |
- name: Create tag | |
run: | | |
NEXT_VERSION=${{ steps.get_version.outputs.version }} | |
git pull | |
git tag -a "${NEXT_VERSION}" -m "${NEXT_VERSION}" | |
git push --follow-tags | |
git checkout "${NEXT_VERSION}" | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v6 | |
with: | |
distribution: goreleaser | |
version: latest | |
workdir: action | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
release-docker: | |
# There is a depth limit on workflows triggered by workflows to avoid infinite loops. | |
# This release workflow is triggered by merging a Pull Request made by release-prepare workflow. | |
# | |
# In addition the Docker build cannot really happen because of the `paths` filter in `on.push` event config. | |
# I do not want to change that because then we would build Docker containers all the time, which is long and unnecessary. | |
# | |
# And unfortunately a workflow cannot easily trigger another (Docker container builds) because of other GitHub limits. | |
# However it is possible to use API to trigger a workflow. That is what this job is for. | |
# | |
runs-on: ubuntu-latest | |
permissions: | |
actions: write | |
contents: read | |
packages: write | |
needs: ['release-golang'] | |
if: startsWith(github.event.pull_request.title, 'Release:') && github.event.pull_request.merged == true | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Get tag of current commit | |
id: get_version | |
run: | | |
echo "version=$(git tag --points-at HEAD)" >> "${GITHUB_OUTPUT}" | |
- name: Trigger dagger workflow | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
try { | |
const result = await github.rest.actions.createWorkflowDispatch({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: 'docker-build-and-test.yml', | |
ref: "${{ steps.get_version.outputs.version }}", | |
}) | |
console.log(result); | |
} catch(error) { | |
console.error(error); | |
core.setFailed(error); | |
} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |