Skip to content

Commit 1e345b6

Browse files
committed
Don’t do some CD for 1.x releases
1 parent d1834ab commit 1e345b6

File tree

7 files changed

+41
-58
lines changed

7 files changed

+41
-58
lines changed

.github/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM debian:buster-slim as stage0
22
COPY ./products/* /pkgx/
33
RUN install -m 755 /pkgx/$(uname -m) /usr/local/bin/pkgx
4-
RUN install -m 755 /pkgx/pkgm /usr/local/bin/pkgm
4+
RUN if [ -f /pkgx/pkgm ]; then install -m 755 /pkgx/pkgm /usr/local/bin/pkgm; fi
55
RUN echo 'export PS1="\\[\\033[38;5;63m\\]pkgx\\[\\033[0m\\]\\w $ "' >> /root/.bashrc
66

77
FROM debian:buster-slim as stage1

.github/workflows/cd.brew.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ concurrency:
1111

1212
jobs:
1313
bump-tap:
14+
if: startsWith(github.event.release.tag_name, 2)
1415
runs-on: ubuntu-latest
1516
steps:
1617
- uses: aurelien-baudet/workflow-dispatch@v4

.github/workflows/cd.crates.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ concurrency:
1515

1616
jobs:
1717
publish:
18+
if: startsWith(github.event.release.tag_name, 2)
1819
runs-on: ubuntu-latest
1920
steps:
2021
- uses: actions/checkout@v4

.github/workflows/cd.docker.yml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ permissions:
1919

2020
jobs:
2121
build-and-push-image:
22+
name: docker buildx pkgxdev/pkgx:${{ github.event.release.tag_name || github.event.inputs.tag }}
2223
runs-on: ubuntu-latest
2324
steps:
2425
- uses: robinraju/release-downloader@v1.11
@@ -27,6 +28,19 @@ jobs:
2728
tag: ${{ github.event.inputs.tag }}
2829
fileName: pkgx-*.tar.xz
2930

31+
- name: is_latest?
32+
id: latest
33+
run: |
34+
TAG_NAME="${{ github.event.release.tag_name || github.event.inputs.tag }}"
35+
LATEST_RELEASE=$(gh api repos/${{ github.repository }}/releases/latest --jq '.tag_name')
36+
if [ "$TAG_NAME" == "$LATEST_RELEASE" ]; then
37+
echo "value=true" >> "${GITHUB_OUTPUT}"
38+
else
39+
echo "value=false" >> "${GITHUB_OUTPUT}"
40+
fi
41+
env:
42+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
3044
- name: Unpack Binaries
3145
run: |
3246
for filename in pkgx-*+*+*.tar.xz; do
@@ -41,19 +55,14 @@ jobs:
4155
mv linux+x86-64 products/x86_64
4256
mv linux+aarch64 products/aarch64
4357
44-
curl -o products/pkgm https://pkgxdev.github.io/pkgm/pkgm.ts
58+
- name: Load `pkgm`
59+
run: curl -o products/pkgm https://pkgxdev.github.io/pkgm/pkgm.ts
60+
if: ${{ startsWith(2, github.event.release.tag_name || github.event.inputs.tag) }}
4561

4662
- uses: actions/checkout@v4
4763
with:
4864
path: src
4965

50-
- name: log in to github pkgs
51-
uses: docker/login-action@v3
52-
with:
53-
registry: ghcr.io
54-
username: ${{ github.actor }}
55-
password: ${{ github.token }}
56-
5766
- name: log in to docker hub
5867
uses: docker/login-action@v3
5968
with:
@@ -63,16 +72,14 @@ jobs:
6372
- uses: docker/metadata-action@v5
6473
id: meta
6574
with:
66-
images:
67-
ghcr.io/${{ github.repository }}
68-
pkgxdev/pkgx
75+
images: pkgxdev/pkgx
76+
flavor: |
77+
latest=${{ steps.latest.outputs.value }}
6978
tags: |
7079
type=sha
71-
type=ref,event=branch
72-
type=semver,pattern=v{{version}}
73-
type=semver,pattern=v{{major}}.{{minor}}
74-
type=semver,pattern=v{{major}}
75-
type=raw,value=latest
80+
type=semver,pattern=v{{version}},value=${{ github.event.release.tag_name || github.event.inputs.tag }}
81+
type=semver,pattern=v{{major}}.{{minor}},value=${{ github.event.release.tag_name || github.event.inputs.tag }}
82+
type=semver,pattern=v{{major}},value=${{ github.event.release.tag_name || github.event.inputs.tag }}
7683
7784
- uses: docker/setup-qemu-action@v3
7885
- uses: docker/setup-buildx-action@v3
@@ -87,4 +94,4 @@ jobs:
8794
$tags \
8895
--platform linux/amd64,linux/arm64 \
8996
--file ./src/.github/Dockerfile \
90-
.
97+
.

.github/workflows/cd.vx.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ jobs:
2323
- run: |
2424
git tag -f latest
2525
git push origin latest --force
26+
if: startsWith(github.event.release.tag_name, 2)

.github/workflows/cd.www.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ concurrency:
1717

1818
jobs:
1919
www-upload:
20+
if: startsWith(github.event.release.tag_name, 2)
2021
runs-on: ubuntu-latest
2122
steps:
2223
- uses: aws-actions/configure-aws-credentials@v4

scripts/publish-release.sh

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
#!/usr/bin/env -S pkgx +git +gh +jq +gum +npx +deno bash -eo pipefail
2-
3-
# the back and forth here is because draft releases cannot trigger
4-
# GitHub Actions 😒
1+
#!/usr/bin/env -S pkgx +git +gh +jq +gum bash -eo pipefail
52

63
if ! git diff-index --quiet HEAD --; then
74
echo "error: dirty working tree" >&2
@@ -13,39 +10,10 @@ if [ "$(git rev-parse --abbrev-ref HEAD)" != main ]; then
1310
exit 1
1411
fi
1512

16-
# ensure we have the latest version tags
17-
git fetch origin -pft
18-
19-
versions="$(git tag | grep '^v[0-9]\+\.[0-9]\+\.[0-9]\+')"
20-
v_latest="$(npx -- semver --include-prerelease $versions | tail -n1)"
21-
22-
_is_prerelease() {
23-
deno run - <<EoTS
24-
import { parse } from "https://deno.land/x/semver/mod.ts";
25-
console.log(parse('$1')?.prerelease.length ? 'true' : 'false');
26-
EoTS
27-
}
13+
v_new=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "pkgx") | .version')
2814

29-
case $1 in
30-
major|minor|patch|prerelease)
31-
v_new=$(npx -- semver bump $v_latest --increment $1)
32-
;;
33-
"")
34-
echo "usage $0 <major|minor|patch|prerelease|VERSION>" >&2
35-
exit 1;;
36-
*)
37-
v_new=$1
38-
;;
39-
esac
40-
41-
if [ $v_new = $v_latest ]; then
42-
echo "$v_new already exists!" >&2
43-
exit 1
44-
fi
45-
46-
is_prerelease=$(_is_prerelease $v_new)
47-
48-
if ! gh release view v$v_new >/dev/null 2>&1; then
15+
case $(gh release view --json isDraft | jq .isDraft) in
16+
'release not found')
4917
gum confirm "prepare draft release for $v_new?" || exit 1
5018

5119
gh release create \
@@ -56,13 +24,17 @@ if ! gh release view v$v_new >/dev/null 2>&1; then
5624
--notes-start-tag=v$v_latest \
5725
--title=v$v_new
5826

59-
git push origin main
60-
else
27+
;;
28+
true)
6129
gum format "> existing $v_new draft found, using that"
6230
echo #spacer
31+
;;
32+
false)
33+
gum format "$v_new already published! edit \`./crates/cli/Cargo.toml\`"
34+
exit 1;;
35+
esac
6336

64-
git push origin main
65-
fi
37+
git push origin main
6638

6739
gh workflow run cd.yml --raw-field version="$v_new"
6840
# ^^ infuriatingly does not tell us the ID of the run

0 commit comments

Comments
 (0)