Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade rosey publishing to the new cc-oss bot #54

Merged
merged 1 commit into from
Mar 19, 2024
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
22 changes: 22 additions & 0 deletions .backstage/get_tag.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const version = process.env.GIT_VERSION;

if (!version) {
console.error("Script expected a GIT_VERSION environment variable");
process.exit(1);
}

// Only allow latest tag if we are releasing a major/minor/patch
if (/^\d+\.\d+\.\d+$/.test(version)) {
console.log("latest");
process.exit(0);
}

// Use the suffix as the tag. i.e. `0.11.0-rc5` -> `rc`
const suffix = version.match(/^\d+\.\d+\.\d+-([a-z]+)/i)?.[1];
if (suffix) {
console.log(suffix.toLowerCase());
process.exit(0);
}

// Fall back to an unknown tag for safety
console.log("unknown");
113 changes: 88 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
needs: publish-github-release
steps:
- name: Clone
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
working-directory: ./wrappers/node
steps:
- name: Clone
uses: actions/checkout@v2
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: release-checksums
Expand All @@ -89,39 +89,95 @@ jobs:
run:
working-directory: ./
steps:
- name: Get Token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v2
with:
application_id: ${{ secrets.CC_OSS_BOT_ID }}
application_private_key: ${{ secrets.CC_OSS_BOT_PEM }}
- name: Clone
uses: actions/checkout@v2
- name: Get Version
run: echo GIT_VERSION="$(git describe --tags | sed 's/^v\(.*\)$/\1/')" >> $GITHUB_ENV
uses: actions/checkout@v3
with:
token: ${{ steps.get_workflow_token.outputs.token }}
- name: Swap to main
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0 # Full fetch
token: ${{ steps.get_workflow_token.outputs.token }}

- name: Get Version
run: echo GIT_VERSION="$(git describe --tags | sed 's/^v\(.*\)$/\1/')" >> $GITHUB_ENV
- name: Get Tag
run: echo GIT_TAG="$(node ./.backstage/get_tag.cjs)" >> $GITHUB_ENV

- uses: actions/download-artifact@v3
with:
name: release
path: build-artifacts
- name: Build Changelog

- name: Build CHANGELOG
if: env.GIT_TAG == 'latest'
run: |
node ./.backstage/changelog.cjs write
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add ./CHANGELOG.md
git commit -m "Changelog for $GIT_VERSION"
git push
git checkout production-docs
git merge --no-ff main -m "Release documentation for $GIT_VERSION"
git push
echo CHANGELOG=\"$(base64 -w 0 -i CHANGELOG.md)\" >> $GITHUB_ENV
echo SHA=\"$( git rev-parse main:CHANGELOG.md )\" >> $GITHUB_ENV
- name: Build CHANGELOG
if: env.GIT_TAG != 'latest'
run: |
echo "## Prerelease" > RELEASE.md
node ./.backstage/changelog.cjs write || true

- name: Commit new CHANGELOG
uses: octokit/[email protected]
if: env.GIT_TAG == 'latest'
id: push_changes
with:
route: PUT /repos/{owner}/{repo}/contents/CHANGELOG.md
owner: cloudcannon
repo: rosey
branch: main
message: Changelog for ${{ env.GIT_VERSION }}
sha: ${{ env.SHA }}
content: ${{ env.CHANGELOG }}
env:
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
- name: Release documentation branch
uses: octokit/[email protected]
if: env.GIT_TAG == 'latest'
id: merge_docs
with:
route: POST /repos/{owner}/{repo}/merges
owner: cloudcannon
repo: rosey
base: production-docs
head: main
commit_message: Release documentation for ${{ env.GIT_VERSION }}
env:
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/') && env.GIT_TAG == 'latest'
with:
repository: cloudcannon/rosey
prerelease: false
body_path: RELEASE.md
files: |
build-artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && env.GIT_TAG != 'latest'
with:
repository: cloudcannon/rosey
prerelease: true
body_path: RELEASE.md
files: |
build-artifacts/*
env:
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}

test-and-build:
name: Test and Build
Expand Down Expand Up @@ -152,12 +208,12 @@ jobs:
musl: false
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
Expand All @@ -174,8 +230,11 @@ jobs:
# From https://github.com/Emoun/duplicate/blob/master/.github/workflows/rust.yml
- name: Get Version
run: echo GIT_VERSION="$(git describe --tags | sed 's/^v\(.*\)$/\1/')" >> $GITHUB_ENV
- name: Get Tag
run: echo GIT_TAG="$(node ./.backstage/get_tag.cjs)" >> $GITHUB_ENV

- name: Verify Changelog
if: env.GIT_TAG == 'latest'
run: |
node ./.backstage/changelog.cjs

Expand All @@ -189,12 +248,16 @@ jobs:
run: |
sudo apt update
sudo apt install -y musl-tools musl-dev
- name: Install Rust
run: |
rustup install ${{ matrix.rust }}
rustup target add ${{ matrix.target }}
rustup show

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
default: true
components: rustfmt, clippy

- name: Install humane
uses: supplypike/setup-bin@v1
with:
Expand Down
Loading