Skip to content

Update workflow pins #1

Update workflow pins

Update workflow pins #1

Workflow file for this run

name: 'Release'
on:
workflow_call:
jobs:
release:
name: 'Release'
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744' # ratchet:actions/checkout@v3
- name: 'Get package version'
run: |-
echo "NEW_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV
- name: 'Get previous release tag'
uses: 'actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410' # ratchet:actions/github-script@v6
with:
script: |-
try {
const latestRelease = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
});
core.exportVariable("PREV_TAG", latestRelease.data.tag_name);
} catch (err) {
if (err["status"] === 404) {
core.info(`No releases found`);
} else {
core.setFailed(`Failed to load latest release: ${err}`);
}
}
- name: 'Create release'
uses: 'actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410' # ratchet:actions/github-script@v6
with:
script: "const tag = \"v\" + process.env.NEW_VERSION;\n\ntry {\n const createReleaseRequest = {\n owner: context.repo.owner,\n repo: context.repo.repo,\n tag_name: tag,\n target_commitish: context.sha,\n name: tag,\n generate_release_notes: true,\n };\n\n if (process.env.PREV_TAG) {\n const releaseNotes = await github.rest.repos.generateReleaseNotes({\n owner: context.repo.owner,\n repo: context.repo.repo,\n tag_name: tag,\n target_commitish: context.sha,\n previous_tag_name: process.env.PREV_TAG,\n });\n \n createReleaseRequest.body = releaseNotes.data.body;\n createReleaseRequest.generate_release_notes = false;\n }\n\n const response = await github.rest.repos.createRelease(createReleaseRequest);\n\n core.info(\n `Created release ${response.data.name} at ${response.data.html_url}`\n );\n} catch (err) {\n core.setFailed(`Failed to create release: ${err}`);\n}"
uses: 'actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410' # ratchet:actions/github-script@v6
try {
const createReleaseRequest = {
owner: context.repo.owner,

Check failure on line 43 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

You have an error in your yaml syntax on line 43
repo: context.repo.repo,
tag_name: tag,
target_commitish: context.sha,
name: tag,
generate_release_notes: true,
};
if (process.env.PREV_TAG) {
const releaseNotes = await github.rest.repos.generateReleaseNotes({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tag,
target_commitish: context.sha,
previous_tag_name: process.env.PREV_TAG,
});
createReleaseRequest.body = releaseNotes.data.body;
createReleaseRequest.generate_release_notes = false;
}
const response = await github.rest.repos.createRelease(createReleaseRequest);
core.info(
`Created release ${response.data.name} at ${response.data.html_url}`
);
} catch (err) {
core.setFailed(`Failed to create release: ${err}`);
}
- name: 'Update floating tag'
uses: 'actions/github-script@v6'
with:
script: |-
const tag = "v" + process.env.NEW_VERSION;
const major = tag.split(".")[0];
// Try to update the ref first. If that fails, it probably does not
// exist yet, and we should create it.
try {
await github.rest.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/" + major,
sha: context.sha,
force: true,
});
core.info(`Updated ${major} to ${context.sha}`);
} catch (err) {
core.warning(`Failed to create tag ${major}: ${err}`);
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/" + major,
sha: context.sha,
});
core.info(`Created ${major} at ${context.sha}`);
}