Skip to content

Update CHANGELOG (#525) #340

Update CHANGELOG (#525)

Update CHANGELOG (#525) #340

Workflow file for this run

name: Release
on:
push:
branches:
- main
workflow_dispatch:
inputs:
sha:
description: "Commit SHA of the release merge commit (defaults to HEAD of main)"
required: false
default: ""
concurrency:
group: release-${{ github.sha }}
cancel-in-progress: false
jobs:
create_release:
name: Create release
runs-on: ubuntu-latest
outputs:
is_release: ${{ steps.detect_release.outputs.is_release }}
release_branch: ${{ steps.detect_release.outputs.release_branch }}
permissions:
contents: read
id-token: write
pull-requests: read
steps:
- name: Detect release
id: detect_release
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
try {
const commitSha = context.payload.inputs?.sha || context.sha;
let releasePR = null;
for (let attempt = 1; attempt <= 6; attempt++) {
const prs = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: commitSha
});
const releasePRs = prs.data
.filter(pr => pr.merged_at && pr.head.ref.startsWith('release/'))
.sort((a, b) => new Date(b.merged_at) - new Date(a.merged_at));
releasePR = releasePRs[0];
if (releasePR) break;
core.info(`Attempt ${attempt}/6: no release PR found yet, waiting 10s...`);
await new Promise(r => setTimeout(r, 10000));
}
if (releasePR) {
core.setOutput('is_release', 'true');
core.setOutput('release_branch', releasePR.head.ref);
core.info(`Detected release PR: ${releasePR.head.ref}`);
} else {
core.setOutput('is_release', 'false');
core.setOutput('release_branch', '');
core.info('No release PR detected for this push — skipping release steps');
}
} catch (e) {
core.setFailed(`Failed to detect release PR: ${e.message}`);
}
- name: Get access token
if: steps.detect_release.outputs.is_release == 'true'
uses: DataDog/dd-octo-sts-action@96a25462dbcb10ebf0bfd6e2ccc917d2ab235b9a # v1.0.4
id: octo-sts
with:
scope: DataDog/datadog-sync-cli
policy: self.release.create-release
- name: Create release
if: steps.detect_release.outputs.is_release == 'true'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
env:
RELEASE_BRANCH: ${{ steps.detect_release.outputs.release_branch }}
with:
github-token: ${{ steps.octo-sts.outputs.token }}
script: |
const tagName = `${process.env.RELEASE_BRANCH.split("/")[1]}`;
let tagExists = false;
try {
await github.rest.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `tags/${tagName}`,
});
tagExists = true;
core.warning(`Tag ${tagName} already exists — skipping creation`);
} catch (e) {
if (e.status !== 404) throw e;
}
if (!tagExists) {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${tagName}`,
sha: context.sha,
});
}
let releaseExists = false;
try {
await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tagName,
});
releaseExists = true;
core.warning(`Release ${tagName} already exists — skipping creation`);
} catch (e) {
if (e.status !== 404) throw e;
}
if (!releaseExists) {
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
generate_release_notes: true,
tag_name: tagName,
});
}
build_artifacts:
needs: create_release
if: needs.create_release.outputs.is_release == 'true'
name: Build executables
permissions:
contents: write
strategy:
matrix:
os: [ubuntu-22.04-arm, ubuntu-22.04, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Set tag
env:
RELEASE_BRANCH: ${{ needs.create_release.outputs.release_branch }}
run: |
TAG_NAME=$(echo "$RELEASE_BRANCH" | cut -d "/" -f2)
echo "tag_name=$TAG_NAME" >> "$GITHUB_ENV"
shell: bash
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ env.tag_name }}
fetch-depth: 0
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.12"
- name: Install requirements
run: |
python -m pip install .
python -m pip install -r scripts/build_requirements.txt
- name: Build and upload executables
run: python scripts/build.py -f -u
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}