Skip to content

Commit

Permalink
chore: release workflow (#1041)
Browse files Browse the repository at this point in the history
## Description
Updates the version of the SLSA release without the V so provenance
works

## Related Issue

Fixes #
<!-- or -->
Relates to #

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Other (security config, docs update, etc)

## Checklist before merging

- [x] Test, docs, adr added or updated as needed
- [x] [Contributor Guide
Steps](https://docs.pepr.dev/main/contribute/#submitting-a-pull-request)
followed

---------

Signed-off-by: Case Wylie <cmwylie19@defenseunicorns.com>
  • Loading branch information
cmwylie19 authored Aug 7, 2024
1 parent fc689d8 commit a1bed17
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 54 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,11 @@ jobs:
npm install -g npm
npm --no-git-tag-version version ${{ github.ref_name }}
npm run version
# Build Controller Image
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag ghcr.io/defenseunicorns/pepr/controller:${{ github.ref_name }} .
# Build Pepr dist folder for NPM
docker buildx build --output="." --target=dist --no-cache . -f Dockerfile.dist
slsa:
permissions:
id-token: write
Expand Down
22 changes: 0 additions & 22 deletions Dockerfile.dist

This file was deleted.

61 changes: 33 additions & 28 deletions scripts/set-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,38 @@

const fs = require("fs");

const packageJSON = require("../package.json")
const packageLockJSON = require("../package-lock.json")

const version = process.env.GITHUB_REF_NAME;

const packageJSONVersion = (packageJSON) => {
packageJSON.version = version;
writeToFile("./package.json", packageJSON);
}
const packageLockJSONVersion = (packageLockJSON) => {
packageLockJSON.version = version;
packageLockJSON.packages[""].version = version;
writeToFile("./package-lock.json", packageLockJSON);
}
const packageJSON = require("../package.json");
const packageLockJSON = require("../package-lock.json");

const generateVersion = () => {
let version = "";
version = process.env.GITHUB_REF_NAME.split("");
version = version[0] === "v" ? version.slice(1) : version;
return version.join("");
};

const packageJSONVersion = (packageJSON, version) => {
packageJSON.version = version;
writeToFile("./package.json", packageJSON);
};
const packageLockJSONVersion = (packageLockJSON, version) => {
packageLockJSON.version = version;
packageLockJSON.packages[""].version = version;
writeToFile("./package-lock.json", packageLockJSON);
};

const writeToFile = (file, data) => {
return new Promise((resolve, reject) => {
fs.writeFile(file, JSON.stringify(data, null, 2), (err) => {
if (err) {
reject(err);
} else {
resolve();
}
});
})
}


packageJSONVersion(packageJSON);
packageLockJSONVersion(packageLockJSON);
return new Promise((resolve, reject) => {
fs.writeFile(file, JSON.stringify(data, null, 2), err => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
};

const version = generateVersion();
packageJSONVersion(packageJSON, version);
packageLockJSONVersion(packageLockJSON, version);

0 comments on commit a1bed17

Please sign in to comment.