-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial PR-based artifact update workflow (#15)
- Loading branch information
Showing
7 changed files
with
317 additions
and
20 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "Artifacts.toml" | ||
jobs: | ||
publish: | ||
name: Publish | ||
runs-on: ubuntu-latest | ||
# These permissions are needed to: | ||
# - Create a GitHub release: https://github.com/ncipollo/release-action#notes | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Determine artifact details | ||
id: details | ||
shell: julia --color=yes {0} | ||
run: | | ||
using Pkg.Types: read_project | ||
include(joinpath(pwd(), "gen", "artifacts.jl")) | ||
(; key, tarball_filename) = gh_artifact() | ||
project = read_project("Project.toml") | ||
open(ENV["GITHUB_OUTPUT"], "a") do io | ||
println(io, "key=$key") | ||
println(io, "tarball_filename=$tarball_filename") | ||
println(io, "tag=v$(project.version)") | ||
end | ||
- uses: dawidd6/action-download-artifact@v3 | ||
id: action-artifact | ||
with: | ||
workflow: Update.yaml | ||
name: ${{ steps.details.outputs.key }} | ||
# As `ncipollo/release-action`'s `artifactErrorsFailBuild` input will still cause a release | ||
# to be created we'll perform this check to fail earlier. | ||
- name: Validate artifact retrieved | ||
run: | | ||
[ -f "${{ steps.details.outputs.tarball_filename }}" ] || exit 1 | ||
- name: Build Changelog | ||
id: build_changelog | ||
uses: mikepenz/release-changelog-builder-action@v4 | ||
- name: Publish Release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
tag: ${{ steps.details.outputs.tag }} | ||
body: ${{ steps.build_changelog.outputs.changelog }} | ||
artifacts: ${{ steps.details.outputs.tarball_filename }} | ||
artifactErrorsFailBuild: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
name: Update | ||
on: | ||
schedule: | ||
- cron: "*/5 * * * *" # Every 5 minutes (for now) | ||
jobs: | ||
artifacts: | ||
name: Artifacts | ||
runs-on: ubuntu-latest | ||
# These permissions are needed to: | ||
# - Create PRs: https://github.com/marketplace/actions/create-pull-request#workflow-permissions | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
env: | ||
JULIA_PROJECT: gen | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || 'main' }} | ||
- uses: julia-actions/setup-julia@v1 | ||
with: | ||
version: "1" | ||
- uses: julia-actions/cache@v1 | ||
- name: Instantiate | ||
shell: julia --color=yes {0} | ||
run: | | ||
using Pkg | ||
Pkg.instantiate() | ||
- name: Build tzdata | ||
id: build | ||
shell: julia --color=yes {0} | ||
run: | | ||
include(joinpath(pwd(), "gen", "make.jl")) | ||
(; tarball_path, tarball_sha256, new_version, commit_message) = update_tzdata() | ||
key = basename(tarball_path) * "-" * tarball_sha256 | ||
@show key tarball_path commit_message | ||
open(ENV["GITHUB_OUTPUT"], "a") do io | ||
println(io, "key=$key") | ||
println(io, "tarball_path=$tarball_path") | ||
println(io, "commit_message=$commit_message") | ||
end | ||
println("workflow_ref=${{ github.workflow_ref }}") | ||
- run: git diff | ||
# Store the Julia artifact tarball as a GitHub actions artifact. This will allow us to retrieve this | ||
# tarball from other workflows. | ||
- uses: actions/upload-artifact@v4 | ||
id: action-artifact | ||
with: | ||
name: ${{ steps.build.outputs.key }} | ||
path: ${{ steps.build.outputs.tarball_path }} | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
base: main # Shouldn't be required for `workflow_dispatch` | ||
title: ${{ steps.build.outputs.commit_message }} | ||
body: >- | ||
An automated PR generated by the ${{ github.workflow }} workflow. | ||
add-paths: | | ||
Project.toml | ||
Artifacts.toml | ||
commit-message: ${{ steps.build.outputs.commit_message }} | ||
branch: gh/update-tzdata | ||
delete-branch: ${{ github.event_name == 'pull_request' }} | ||
token: ${{ secrets.TZJDATA_UPDATE_TOKEN }} # TODO: Fine-grained token expires |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using TOML: TOML | ||
|
||
const PKG_ROOT = joinpath(@__DIR__(), "..") | ||
|
||
function gh_artifact(artifact_toml=joinpath(PKG_ROOT, "Artifacts.toml")) | ||
toml = TOML.parsefile(artifact_toml) | ||
tarball_artifact = only(toml["tzjdata"]["download"]) | ||
tarball_filename = basename(tarball_artifact["url"]) | ||
tarball_sha256 = tarball_artifact["sha256"] | ||
content_hash = toml["tzjdata"]["git-tree-sha1"] | ||
|
||
key = "$(tarball_filename)-$(tarball_sha256)" | ||
return (; | ||
tarball_filename, | ||
tarball_sha256, | ||
content_hash, | ||
key, | ||
) | ||
end |
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
Oops, something went wrong.