Build changelogs using GHA #29
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
name: "Publish Pre-Release" | |
on: | |
workflow_dispatch: | |
inputs: | |
commit: | |
# Note: The tag itself will not be based off this commit. As we must first commit the | |
# updates to the Artifacts.toml, then the tag will be based off that commit. | |
description: The commit to branch from when making the tag | |
required: true | |
push: | |
# Force a single workflow to run at a time. This ensures we don't accidentally | |
# try to perform concurrent publishing of releases. | |
concurrency: publish-release | |
env: | |
build_dir: ./build | |
tarballs_dir: ./build/tarballs | |
jobs: | |
release: | |
name: "Publish Pre-Release" | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Needed determine tags | |
persist-credentials: true | |
ref: ${{ inputs.commit }} | |
- name: Check for new Project version | |
id: project_toml | |
shell: julia --color=yes --project {0} | |
run: | | |
using Pkg.Types | |
project = read_project("Project.toml") | |
tags = parse.(VersionNumber, split(readchomp(`git tag -l`), "\n")) | |
@info "Project version: project.version" | |
project.version in tags && error("Tag v$(project.version) already exists") | |
open(ENV["GITHUB_OUTPUT"], "a") do io | |
println(io, "version=$(project.version)") | |
println(io, "tag=v$(project.version)") | |
end | |
- name: Download artifacts | |
id: download-artifact | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
commit: ${{ inputs.commit }} # pull the artifacts for the given commit | |
name: ray_julia_libraries | |
path: ${{ env.tarballs_dir }} | |
workflow: CI.yml | |
- uses: julia-actions/setup-julia@v1 | |
with: | |
version: "1.8" | |
arch: "x64" | |
- uses: julia-actions/cache@v1 | |
with: | |
cache-name: "${{ github.workflow }}-${{ github.job }}" | |
- name: Update Artifacts.toml | |
shell: julia --color=yes --project {0} | |
run: | | |
using Pkg | |
Pkg.instantiate() | |
include(joinpath(pwd(), "bind_artifacts.jl")) | |
bind_artifacts() | |
working-directory: ${{ env.build_dir }} | |
- name: Commit Changes | |
id: commit | |
run: | | |
# Alternatively environment variables can be used but both author/committer need to be set | |
# https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables#_committing | |
git config user.name beacon-buddy | |
git config user.email [email protected] | |
msg="Update Artifacts.toml to use ${{ steps.project_toml.outputs.version }} assets" | |
git checkout --detach | |
git commit -m "$msg" -- Artifacts.toml | |
echo "sha=$(git rev-parse HEAD)" | tee -a "$GITHUB_OUTPUT" | |
- name: Tag and push | |
run: | | |
tag=${{ steps.project_toml.outputs.tag }} | |
git tag $tag ${{ steps.commit.outputs.sha }} | |
git push origin $tag | |
- name: "Build Changelog" | |
id: build_changelog | |
uses: mikepenz/release-changelog-builder-action@v4 | |
- name: Publish Pre-Release | |
uses: ncipollo/release-action@v1 | |
with: | |
prerelease: true | |
tag: ${{ steps.project_toml.outputs.tag }} | |
artifacts: ${{ env.tarballs_dir }}/*.tar.gz | |
generateReleaseNotes: true | |
body: ${{ steps.build_changelog.outputs.changelog }} |