Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

(IGNORE) Add nightly build process #139

Merged
merged 2 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 149 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Nightly build

on:
workflow_dispatch:
schedule:
- cron: "30 5 * * *" # 0530 UTC every day

jobs:
# Create snapshot of main branch for nightly build
nightly-snapshot:
name: Create snapshot
runs-on: ubuntu-latest

outputs:
new-tag: ${{ steps.set-nightly-version.outputs.version }}

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GH_ADMIN_COMMIT_TOKEN }}

- name: Get latest existing tag
uses: WyriHaximus/github-action-get-previous-tag@v1
id: get-latest-tag

- name: Set new proposed version
uses: paulhatch/[email protected]
id: set-version
with:
tag_prefix: "v"
version_format: "${major}.${minor}.${patch}"
major_pattern: "(MAJOR)"
minor_pattern: "(MINOR)"

- name: Add -nightly+(date)-(commit ID) prefix to version
id: set-nightly-version
run: |
echo version=${{ steps.set-version.outputs.version }}-nightly+`date +%F`-`git rev-parse --short HEAD` >> "$GITHUB_OUTPUT"

- name: Generate changelog since last tag
id: generate-changelog
run: |
{
echo 'changelog<<EOF'
git log --format="* %s" ${{ steps.get-latest-tag.outputs.tag }}..HEAD | { grep -v "(IGNORE)" || :; }
echo EOF
} >> "$GITHUB_OUTPUT"

- name: Log new version & changelog
run: |
echo "Proposed new version: $VERSION"
echo "Nightly version: $NIGHTLY_VERSION"
echo "Latest tag detected: $LATEST_TAG"
echo "Changelog: $CHANGELOG"
env:
VERSION: ${{ steps.set-version.outputs.version }}
NIGHTLY_VERSION: ${{ steps.set-nightly-version.outputs.version }}
LATEST_TAG: ${{ steps.get-latest-tag.outputs.tag }}
CHANGELOG: ${{ steps.generate-changelog.outputs.changelog }}

- name: Bump crate versions
run: |
sed -i "s/^version = \"[^\"]*\"$/version = \"$VERSION\"/;" Cargo.toml
env:
VERSION: ${{ steps.set-nightly-version.outputs.version }}

- name: Swap in nightly c2pa-rs build
run: |
sed -i "s/^c2pa = { version = \"[^\"]*\",/c2pa = { git = \"https:\\/\\/github.com\\/contentauth\\/c2pa-rs.git\", branch = \"nightly\",/;" Cargo.toml

- name: Update changelog
run: |
(head -8 CHANGELOG.md && echo "## $VERSION" && date "+_%d %B %Y_" && echo "" && (echo "$CHANGELOG" | sed -E 's_\(#([0-9]+)\)_([#\1](https://github.com/contentauth/c2pa-rs/pull/\1)\)_') && tail -n +9 CHANGELOG.md) > CHANGELOG.new.md
mv CHANGELOG.new.md CHANGELOG.md
env:
VERSION: ${{ steps.set-version.outputs.version }}
CHANGELOG: ${{ steps.generate-changelog.outputs.changelog }}

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: cargo

- name: Create or update Cargo.lock
run: |
cargo update -w
git add -f Cargo.lock

- name: Report differences for "prepare (release)" commit
run: git diff

- name: Commit Cargo.toml, Cargo.lock, and changelog
uses: stefanzweifel/git-auto-commit-action@v4
id: commit
with:
branch: nightly
push_options: '--force'
commit_message: Prepare ${{ steps.set-nightly-version.outputs.version }} release
commit_user_name: Adobe CAI Team
commit_user_email: [email protected]
create_branch: true

publish-nightly-binaries:
name: Publish c2patool nightly binaries
runs-on: ${{ matrix.os }}
needs: nightly-snapshot

strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
include:
- os: macos-latest
artifact_name: c2patool_mac_universal.zip
- os: ubuntu-latest
artifact_name: c2patool_linux_intel.tar.gz
- os: windows-latest
artifact_name: c2patool_win_intel.zip

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: nightly

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2

- name: Run cargo check
run: cargo check

- name: Run cargo test --all
run: cargo test --all

- name: Build nightly release artifacts
run: make release

- name: Upload build as artifact
uses: actions/upload-artifact@v3
with:
path: target/${{ matrix.artifact_name }}
name: ${{ matrix.artifact_name }}
retention-days: 15
if-no-files-found: error
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,7 @@ For example, the following command adds a custom assertion called "org.contentau
```shell
c2patool sample/image.jpg -c '{"assertions": [{"label": "org.contentauth.test", "data": {"my_key": "whatever I want"}}]}'
```

## Nightly builds

Interim binaries are generated every day around 0530 UTC (i.e. overnight for our US-based team) and are available for roughly two weeks thereafter. These can be helpful for testing purposes. For more information, see the documentation on [nightly builds](/docs/nightly-builds/README.md).
32 changes: 32 additions & 0 deletions docs/nightly-builds/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# About c2patool nightly builds

Interim binaries are generated every day around 0530 UTC (i.e. overnight for our US-based team) and are available for roughly two weeks thereafter. These can be helpful for testing purposes.

## Finding nightly builds

Start by clicking on the [Actions](https://github.com/contentauth/c2patool/actions) tab for the repo and then click on the ["Nightly build" entry on the left side](https://github.com/contentauth/c2patool/actions/workflows/nightly.yml).

In this screen, you'll see a history of recent nightly builds, something like this:

![Nightly build runs](./nightly-build-runs.png)

Click on the build description (for example, "Use v2 of rust-cache" in this list). That will lead to a summary screen similar to the following:

![Nightly build summary](./nightly-build-summary.png)

In the **"Artifacts"** section at the bottom are archives containing the `c2patool` binary and relevant sample files.

Note that each build contains a unique build number. If you file a bug against a nightly version, we would very much appreciate it if you would include that version ID:

```
$ c2patool --version
c2patool 0.6.2-nightly+2023-08-29-24601f5
```

This build number contains the date of the nightly version and the commit ID (from `main` branch) that was built.

## Important notes about nightly builds

* CAI team members may occasionally trigger "nightly" builds at other times of the day if there are particularly interesting changes that we need to test.
* Nightly builds of `c2patool` are built with the latest available nightly build of `c2pa-rs`. Typically this is a snapshot of `c2pa-rs` taken at 0500 UTC (i.e. very shortly before the corresponding `c2patool` build).
* This repo contains a `nightly` branch which contains the code for the latest build that was triggered (typically the Cargo.toml and Cargo.lock changes). This branch is force-pushed by the nightly build process; you should not rely on its contents and should not target this build for any pull requests.
Binary file added docs/nightly-builds/nightly-build-runs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/nightly-builds/nightly-build-summary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.