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

PP-12343: Add post merge package and release, and ensure package works on PRs #3

Merged
merged 8 commits into from
Mar 4, 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
87 changes: 87 additions & 0 deletions .github/workflows/post-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Post Merge

on:
push:
branches:
- main

permissions:
contents: read

jobs:
tests:
uses: ./.github/workflows/run-tests.yml

release-package:
needs: tests
runs-on: ubuntu-latest

permissions:
contents: write

name: Check for, and perform release
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
fetch-depth: '0'
- name: Load pkl version
id: load-pkl-version
run: |
PKL_VERSION=$(cat .pkl-version)
echo "PKL_VERSION=${PKL_VERSION}" | tee -a "$GITHUB_OUTPUT"
- name: Install pkl
env:
PKL_VERSION: "${{ steps.load-pkl-version.outputs.PKL_VERSION }}"
run: |
curl -L -o pkl https://github.com/apple/pkl/releases/download/${PKL_VERSION}/pkl-linux-amd64
chmod u+x pkl
./pkl --version
- name: Get pkl module version
id: load-module-version
run: |
set -o pipefail

MODULE_VERSION=$(./pkl eval -f json src/PklProject | jq -r .package.version)
if [ -z "${MODULE_VERSION:-}" ]; then
echo "Couldn't read module version!"
exit 1
fi

echo "MODULE_VERSION=${MODULE_VERSION}" | tee -a "$GITHUB_OUTPUT"
- name: Check for existing release
id: check-for-existing-release
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
env:
MODULE_VERSION: "${{ steps.load-module-version.outputs.MODULE_VERSION }}"
with:
script: |
const module_version = process.env.MODULE_VERSION;
console.log(`Checking for a release of version ${module_version}`)

try {
const release = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: module_version,
})
console.log(`Release found for version ${module_version}, no need to do a new release`)
core.setOutput('RELEASE_EXISTS', 'true')
} catch (error) {
if (error.status === 404) {
console.log("No release found, release required")
core.setOutput('RELEASE_EXISTS', 'false')
return
}
throw error
}
- if: steps.check-for-existing-release.outputs.RELEASE_EXISTS == 'false'
name: Build new version
run: |
./pkl project package src/ --output-path build/
- if: steps.check-for-existing-release.outputs.RELEASE_EXISTS == 'false'
name: Release new version
env:
MODULE_VERSION: "${{ steps.load-module-version.outputs.MODULE_VERSION }}"
run: |
echo "Creating release ${MODULE_VERSION}"
gh release create --create-notes --latest "${MODULE_VERSION}" build/*
20 changes: 16 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Detect secrets
uses: alphagov/pay-ci/actions/detect-secrets@master

Expand All @@ -21,12 +21,21 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
fetch-depth: '0'
- name: Load pkl version
id: load-pkl-version
run: |
PKL_VERSION=$(cat .pkl-version)
echo "PKL_VERSION=${PKL_VERSION}" | tee -a "$GITHUB_OUTPUT"
- name: Install pkl
env:
PKL_VERSION: "${{ steps.load-pkl-version.outputs.PKL_VERSION }}"
run: |

curl -L -o pkl https://github.com/apple/pkl/releases/download/0.25.2/pkl-linux-amd64
curl -L -o pkl https://github.com/apple/pkl/releases/download/${PKL_VERSION}/pkl-linux-amd64
chmod u+x pkl
./pkl --version
- name: Validate Task Config
run: |
set -o pipefail
Expand All @@ -35,3 +44,6 @@ jobs:
run: |
set -o pipefail
./pkl eval tests/pipeline.pkl | diff tests/expected/pipeline.yml -
- name: Validate package can build
run: |
./pkl project package src/ --output-path build/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
1 change: 1 addition & 0 deletions .pkl-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.25.2
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# pkl-concourse-pipeline
A pkl module defining the schema of concourse pipelines

## Releasing new versions

1. Update the version number in [src/PklProject](src/PklProject) in a PR
2. Get approval and Merge the PR

The post-merge workflow will detect there needs to be a new release and will automatically create the new release in GitHub.

## Licence

[MIT License](LICENSE)
Expand Down
Empty file added build/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion src/PklProject
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package {
name = "concourse_pipeline"
version = "0.0.1"
license = "MIT"
baseUri = "package://pkg.pkl-lang.org/github.com/alphagov/pkl-concourse-pipeline"
sourceCode = "https://github.com/alphagov/pkl-concourse-pipeline"
baseUri = "package://pkl.pkl-lang.org/github.com/alphagov/pkl-concourse-pipeline"
sourceCodeUrlScheme = "\(sourceCode)/blob/\(name)@\(version)%{path}#L%{line}-L%{endLine}"
packageZipUrl = "\(sourceCode)/releases/download/\(name)@\(version)/\(name)@\(version).zip"
description = """
Expand Down