Publish #9
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 | |
on: | |
workflow_dispatch: {} | |
env: | |
RELEASER_CHANGER: 'regex-pattern:version = "$1"@Cargo.toml' | |
CRATE_NAME: deflate64 | |
jobs: | |
pre-build: | |
name: Update version name | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.update.outputs.version }} | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: anatawa12/something-releaser@v3 | |
- uses: snow-actions/git-config-user@v1.0.0 | |
- name: update version name | |
id: update | |
run: |- | |
# update version name | |
VERSION="$(get-version)" | |
if ! [[ "$VERSION" = *-SNAPSHOT ]]; then | |
echo 'VERSION IS NOT SNAPSHOT' >&2 | |
exit 1 | |
fi | |
VERSION="$(version-unsnapshot "$VERSION")" | |
gh-set-output version "$VERSION" | |
gh-export-variable VERSION "$VERSION" | |
set-version "$VERSION" | |
# region changelog | |
- name: Create Changelog | |
id: changelog | |
uses: anatawa12/sh-actions/changelog/prepare-release@master | |
with: | |
version: ${{ env.VERSION }} | |
tag-prefix: v | |
release-note-heading: | | |
Version ${{ env.VERSION }} | |
--- | |
- name: Upload CHANGELOG.md | |
uses: actions/upload-artifact@v4 | |
with: | |
name: CHANGELOG | |
path: CHANGELOG.md | |
- run: cp "${{ steps.changelog.outputs.release-note }}" release-note.md | |
- name: Upload release note | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-note | |
path: release-note.md | |
- run: rm release-note.md | |
# endregion changelog | |
# check for unexpected breaking ABI changes | |
- name: Check semver | |
uses: obi1kenobi/cargo-semver-checks-action@v2 | |
- name: commit new release | |
id: commit | |
run: |- | |
# commit & tag | |
git add Cargo.toml CHANGELOG.md | |
git commit -m "v$VERSION" | |
git branch releasing | |
git push -u origin releasing | |
publish-crates-io: | |
name: Publish to crates.io | |
environment: | |
name: crates.io | |
url: https://crates.io/crates/${{ env.CRATE_NAME }} | |
runs-on: ubuntu-latest | |
needs: [pre-build] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: 'releasing' | |
fetch-depth: 1 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Publish CARGO | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | |
run: cargo publish | |
publish: | |
name: Publish to GitHub | |
environment: | |
name: actions-github-app | |
url: https://github.com/${{ github.repository }}/releases/v${{ needs.pre-build.outputs.version }} | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
needs: [publish-crates-io, pre-build] | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ secrets.APP_ID }} | |
private-key: ${{ secrets.PRIVATE_KEY }} | |
- uses: actions/checkout@v4 | |
with: | |
ref: 'releasing' | |
fetch-depth: 2 | |
token: ${{ steps.app-token.outputs.token }} | |
# tools | |
- uses: anatawa12/something-releaser@v3 | |
- uses: snow-actions/git-config-user@v1.0.0 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Push tag | |
env: | |
VERSION: ${{ needs.pre-build.outputs.version }} | |
run: |- | |
# set tag and publish current version | |
git tag "v$VERSION" | |
git push && git push --tags | |
# create master and push | |
git switch -c master | |
git fetch origin master --depth=1 | |
git log --all --graph | |
git push -u origin master | |
- name: download release note for this release | |
uses: actions/download-artifact@v4 | |
id: download-release-note | |
with: | |
name: release-note | |
- name: create release | |
shell: bash | |
env: | |
VERSION: ${{ needs.pre-build.outputs.version }} | |
GH_TOKEN: ${{ github.token }} | |
RELEASE_NOTE: ${{ steps.download-release-note.outputs.download-path }}/release-note.md | |
run: |- | |
sleep 1 | |
gh release create --verify-tag "v$VERSION" --notes-file "$RELEASE_NOTE" | |
- name: Update To Next Version | |
run: | | |
VERSION="$(get-version)" | |
VERSION="$(version-next "$VERSION")" | |
set-version "$(version-snapshot "$VERSION")" | |
git add Cargo.toml | |
git commit -m "prepare for next version: $VERSION" | |
git push | |
git push --delete origin releasing |