This repository has been archived by the owner on Dec 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
144 lines (120 loc) · 4.38 KB
/
nightly.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
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
steps:
- name: Checkout repository
uses: actions/checkout@v4
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 "Changelog: $CHANGELOG"
env:
VERSION: ${{ steps.set-version.outputs.version }}
NIGHTLY_VERSION: ${{ steps.set-nightly-version.outputs.version }}
CHANGELOG: ${{ steps.generate-changelog.outputs.changelog }}
- name: Bump c2patool crate version
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/c2patool/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: [windows-latest, macos-latest, ubuntu-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@v4
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