diff --git a/.craft.yml b/.craft.yml index 839f1161..251f73f6 100644 --- a/.craft.yml +++ b/.craft.yml @@ -1,22 +1,25 @@ -minVersion: 1.0.0 -changelogPolicy: auto +minVersion: 2.18.0 artifactProvider: name: none statusProvider: name: github config: contexts: - - 'build-amd64' - - 'build-arm64' - - 'assemble-image' + - build-amd64 + - build-arm64 + - assemble-image targets: - - name: github - - id: release - name: docker - source: ghcr.io/getsentry/vroom - target: getsentry/vroom - - id: latest - name: docker - source: ghcr.io/getsentry/vroom - target: getsentry/vroom - targetFormat: '{{{target}}}:latest' +- name: github +- id: release + name: docker + source: ghcr.io/getsentry/vroom + target: getsentry/vroom +- id: latest + name: docker + source: ghcr.io/getsentry/vroom + target: getsentry/vroom + targetFormat: '{{{target}}}:latest' +versioning: + policy: calver +changelog: + policy: auto diff --git a/.github/actions/changelog/.gitignore b/.github/actions/changelog/.gitignore deleted file mode 100644 index 504afef8..00000000 --- a/.github/actions/changelog/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules/ -package-lock.json diff --git a/.github/actions/changelog/README.md b/.github/actions/changelog/README.md deleted file mode 100644 index 78d58832..00000000 --- a/.github/actions/changelog/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Changelog Checker - -This is a custom script to check if the changelog files contain the entry for the current pull request. - - -### Development - -To make any contributions or changes to this code you must make sure that you have `node` installed. Once you have it, just -run `npm install` in this folder to install all the dependencies. - -The main entry point is `changelog.js` file. This file contain all the supported checks. diff --git a/.github/actions/changelog/index.js b/.github/actions/changelog/index.js deleted file mode 100644 index ac409983..00000000 --- a/.github/actions/changelog/index.js +++ /dev/null @@ -1,96 +0,0 @@ -module.exports = async ({github, context, core}) => { - const PR_LINK = `[#${context.payload.pull_request.number}](${context.payload.pull_request.html_url})`; - - function getCleanTitle(title) { - // remove fix(component): prefix - title = title.split(': ').slice(-1)[0].trim(); - // remove links to JIRA tickets, i.e. a suffix like [ISSUE-123] - title = title.split('[')[0].trim(); - // remove trailing dots - title = title.replace(/\.+$/, ''); - - return title; - } - - function getChangelogDetails(title) { - return ` - For changes to the _vroom_, please add an entry to \`CHANGELOG.md\` under the following heading: - 1. **Features**: For new user-visible functionality. - 2. **Bug Fixes**: For user-visible bug fixes. - 3. **Internal**: For features and bug fixes in internal operation, especially processing mode. - To the changelog entry, please add a link to this PR (consider a more descriptive message): - \`\`\`md - - ${title}. (${PR_LINK}) - \`\`\` - If none of the above apply, you can opt out by adding _#skip-changelog_ to the PR description. - `; - } - - function logOutputError(title) { - core.info(''); - core.info('\u001b[1mInstructions and example for changelog'); - core.info(getChangelogDetails(title)); - core.info(''); - core.info('\u001b[1mSee check status:'); - core.info( - `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}` - ); - } - - async function containsChangelog(path) { - const {data} = await github.rest.repos.getContent({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: context.ref, - path, - }); - const buf = Buffer.alloc(data.content.length, data.content, data.encoding); - const fileContent = buf.toString(); - return fileContent.includes(PR_LINK); - } - - async function checkChangelog(pr) { - if ((pr.body || '').includes('#skip-changelog')) { - core.info('#skip-changelog is set. Skipping the checks.'); - return; - } - - const hasChangelog = (await containsChangelog('CHANGELOG.md')); - - if (!hasChangelog) { - core.error('Please consider adding a changelog entry for the next release.', { - title: 'Missing changelog entry.', - file: 'CHANGELOG.md', - startLine: 3, - }); - const title = getCleanTitle(pr.title); - core.summary - .addHeading('Instructions and example for changelog') - .addRaw(getChangelogDetails(title)) - .write(); - core.setFailed('CHANGELOG entry is missing.'); - logOutputError(title); - return; - } - - core.summary.clear(); - core.info("CHANGELOG entry is added, we're good to go."); - } - - async function checkAll() { - const {data: pr} = await github.rest.pulls.get({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number, - }); - - // While in draft mode, skip the check because changelogs often cause merge conflicts. - if (pr.merged || pr.draft) { - return; - } - - await checkChangelog(pr); - } - - await checkAll(); -}; diff --git a/.github/actions/changelog/package.json b/.github/actions/changelog/package.json deleted file mode 100644 index 70e3c894..00000000 --- a/.github/actions/changelog/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "ChangelogChecker", - "version": "1.0.0", - "description": "Makes sure that the CHANGELOG.md has the entry for the current pull request.", - "main": "index.js", - "scripts": { - "format": "prettier --write index.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/getsentry/relay.git" - }, - "author": "Oleksandr Kylymnychenko ", - "license": "MIT", - "bugs": { - "url": "https://github.com/getsentry/relay/issues" - }, - "homepage": "https://github.com/getsentry/relay#readme", - "dependencies": { - "@actions/core": "^1.10.0", - "@actions/github": "^5.1.1" - }, - "devDependencies": { - "prettier": "2.8.0" - } -} diff --git a/.github/actions/changelog/prettier.config.js b/.github/actions/changelog/prettier.config.js deleted file mode 100644 index e10965b6..00000000 --- a/.github/actions/changelog/prettier.config.js +++ /dev/null @@ -1,12 +0,0 @@ -/* eslint-env node */ -module.exports = { - bracketSpacing: false, - bracketSameLine: false, - printWidth: 90, - semi: true, - singleQuote: true, - tabWidth: 2, - trailingComma: 'es5', - useTabs: false, - arrowParens: 'avoid', -}; diff --git a/.github/workflows/changelog-preview.yml b/.github/workflows/changelog-preview.yml new file mode 100644 index 00000000..30c6083c --- /dev/null +++ b/.github/workflows/changelog-preview.yml @@ -0,0 +1,18 @@ +name: Changelog Preview +on: + pull_request: + types: + - opened + - synchronize + - reopened + - edited + - labeled + - unlabeled +permissions: + contents: write + pull-requests: write + +jobs: + changelog-preview: + uses: getsentry/craft/.github/workflows/changelog-preview.yml@v2 + secrets: inherit diff --git a/.github/workflows/changelog.yaml b/.github/workflows/changelog.yaml deleted file mode 100644 index f8d49759..00000000 --- a/.github/workflows/changelog.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: changelog -on: - pull_request: - types: [opened, synchronize, reopened, edited, ready_for_review] - -jobs: - build: - name: changelog - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5.0.0 - - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - script: | - const changelog = require('./.github/actions/changelog/index.js') - await changelog({github, context, core}) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a68bfbd8..6c652bda 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -31,10 +31,9 @@ jobs: token: ${{ steps.token.outputs.token }} fetch-depth: 0 - name: Prepare release - uses: getsentry/action-prepare-release@v1 + uses: getsentry/craft@c6e2f04939b6ee67030588afbb5af76b127d8203 env: GITHUB_TOKEN: ${{ steps.token.outputs.token }} with: version: ${{ github.event.inputs.version }} force: ${{ github.event.inputs.force }} - calver: true