c2pa-rs

A fork of https://github.com/contentauth/c2pa-rs/
git clone git://archive.git.mtrnord.blog/mtrnords-photography-manager/c2pa-rs.git
Log | Files | Refs | README

publish.yml (3686B)


      1 name: Publish release
      2 
      3 on:
      4   workflow_dispatch:
      5 
      6 jobs:
      7   publish:
      8     concurrency: publish-mutex
      9     runs-on: ubuntu-latest
     10     steps:
     11 
     12     - name: Checkout
     13       uses: actions/checkout@v3
     14       with:
     15         fetch-depth: 0
     16         token: ${{ secrets.GH_ADMIN_COMMIT_TOKEN }}
     17 
     18     - name: Get latest existing tag
     19       uses: WyriHaximus/github-action-get-previous-tag@v1
     20       id: get-latest-tag
     21 
     22     - name: Set new version
     23       uses: paulhatch/semantic-version@v5.2.1
     24       id: set-version
     25       with:
     26         tag_prefix: "v"
     27         version_format: "${major}.${minor}.${patch}"
     28         major_pattern: "(MAJOR)"
     29         minor_pattern: "(MINOR)"
     30 
     31     - name: Generate changelog since last tag
     32       id: generate-changelog
     33       run: |
     34         {
     35           echo 'changelog<<EOF'
     36           git log --format="* %s" ${{ steps.get-latest-tag.outputs.tag }}..HEAD | { grep -v "(IGNORE)" || :; }
     37           echo EOF
     38         } >> "$GITHUB_OUTPUT"
     39   
     40     - name: Log version & changelog
     41       run: |
     42         echo "Version: $VERSION"
     43         echo "Version tag: $VERSION_TAG"
     44         echo "Latest tag detected: $LATEST_TAG"
     45         echo "Changelog: $CHANGELOG"
     46       env:
     47         VERSION: ${{ steps.set-version.outputs.version }}
     48         VERSION_TAG: ${{ steps.set-version.outputs.version_tag }}
     49         LATEST_TAG: ${{ steps.get-latest-tag.outputs.tag }}
     50         CHANGELOG: ${{ steps.generate-changelog.outputs.changelog }}
     51 
     52     - name: Prevent empty release
     53       if: ${{ steps.generate-changelog.outputs.changelog == '' }}
     54       uses: actions/github-script@v3
     55       with:
     56         script: |
     57           core.setFailed("No changes since prior release")
     58 
     59     - name: Update changelog
     60       run: |
     61         (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)\)_') && echo "" && tail -n +9 CHANGELOG.md) > CHANGELOG.new.md
     62         mv CHANGELOG.new.md CHANGELOG.md
     63       env:
     64         VERSION: ${{ steps.set-version.outputs.version }}
     65         CHANGELOG: ${{ steps.generate-changelog.outputs.changelog }}
     66 
     67     - name: Install Rust toolchain
     68       uses: dtolnay/rust-toolchain@stable
     69 
     70     - name: Bump crate versions
     71       run: |
     72         sed -i "s/^version = \"[^\"]*\"$/version = \"$VERSION\"/;" sdk/Cargo.toml
     73         sed -i "s/^version = \"[^\"]*\"$/version = \"$VERSION\"/;" export_schema/Cargo.toml
     74         sed -i "s/^version = \"[^\"]*\"$/version = \"$VERSION\"/;" make_test_images/Cargo.toml
     75         sed -i "s/^c2pa = \"[^\"]*\"$/c2pa = \"$VERSION\"/;" README.md
     76       env:
     77         VERSION: ${{ steps.set-version.outputs.version }}
     78 
     79     - name: Report differences for "prepare (release)" commit
     80       run: git diff
     81 
     82     - name: Commit Cargo.toml and changelog
     83       uses: stefanzweifel/git-auto-commit-action@v4
     84       id: commit
     85       with:
     86         commit_message: Prepare ${{ steps.set-version.outputs.version }} release
     87         commit_user_name: Adobe CAI Team
     88         commit_user_email: noreply@adobe.com
     89 
     90     - name: Ensure semantic versioning requirements are met
     91       uses: obi1kenobi/cargo-semver-checks-action@v2
     92       with:
     93         package: c2pa
     94 
     95     - name: Create release
     96       uses: ncipollo/release-action@v1
     97       with:
     98         body: ${{ steps.generate-changelog.outputs.changelog }}
     99         commit: ${{ steps.commit.outputs.commit_hash }}
    100         prerelease: true # remove at 1.0
    101         tag: ${{ steps.set-version.outputs.version_tag }}
    102         token: ${{ secrets.GH_ADMIN_COMMIT_TOKEN }}
    103 
    104     - name: Publish crate
    105       run: |
    106         cargo publish --token $CRATES_IO_SECRET -p c2pa
    107       env:
    108         CRATES_IO_SECRET: ${{ secrets.CRATES_IO_SECRET }}