-
Notifications
You must be signed in to change notification settings - Fork 2
151 lines (126 loc) · 5.47 KB
/
Copy pathrelease_and_packages.yml
File metadata and controls
151 lines (126 loc) · 5.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Publish Releases & Packages
on:
push:
tags:
- 'v*'
workflow_dispatch:
# Least privilege at the top, widened per job. The old file granted
# contents: write and packages: write to every job, so the Maven job could have
# pushed packages and the container job could have written the repository.
permissions:
contents: read
# FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 was set here and does nothing. It is not a
# variable the runner reads; the action runtime is chosen by each action's
# own action.yml. Bumping the actions below is the actual fix.
jobs:
publish-releases:
name: Compile Native Binaries & ZIP Drop-in
# ubuntu-22.04 was retired as a GitHub-hosted image. A job pinned to a
# withdrawn label never gets a runner. ubuntu-latest moves with the fleet,
# and the compiler is JDK 8 via setup-java, so the host image does not
# constrain the build.
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Repository
uses: actions/checkout@v7
# setup-java v3 runs on the Node 16 action runtime, which current runners
# refuse to execute. That failure lands on this step, inside this job,
# which is where the reported failure appeared. v4 runs on Node 20.
- name: Setup Java 8
uses: actions/setup-java@v5
with:
java-version: '8'
distribution: 'temurin'
cache: 'maven'
# -B for non-interactive log output. -DskipTests because this repository
# has no src/test, so surefire only costs time.
- name: Compile Native Binaries (Maven)
run: mvn -B clean package -DskipTests
# pom.xml binds maven-jar-plugin to target/dist and binds the dependency
# plugin's copy-dependencies goal to prepare-package writing target/lib,
# so both directories exist after a successful package.
#
# The previous version ended every copy with "|| true" and zipped
# whatever survived. If the build layout ever changed, every copy would
# fail silently and this step would either ship an empty archive or die
# on zip's own "nothing to do" with no explanation. Required paths now
# fail loudly; genuinely optional ones stay optional and say so.
- name: Package ZIP Drop-in
run: |
set -euo pipefail
mkdir -p release-pkg
for required in target/dist target/lib configs scripts; do
if [ ! -d "$required" ]; then
echo "::error::$required is missing. The build layout changed or mvn package did not produce it."
exit 1
fi
done
cp -r target/dist/* release-pkg/
cp -r target/lib release-pkg/
cp -r configs release-pkg/
cp -r scripts release-pkg/
# Launch scripts are a convenience, not a build output.
cp launch_*.sh release-pkg/ 2>/dev/null || echo "no launch_*.sh at repository root, continuing"
if [ -z "$(ls -A release-pkg)" ]; then
echo "::error::release-pkg is empty, refusing to publish an empty archive."
exit 1
fi
cd release-pkg
REF_NAME="${{ github.ref_name }}"
SAFE_REF_NAME="${REF_NAME//\//-}"
zip -r "../OriginalMS-${SAFE_REF_NAME}.zip" .
- name: Upload Release Artifact
# v1 is a Node 16 action. v2 runs on Node 20.
uses: softprops/action-gh-release@v3
if: startsWith(github.ref, 'refs/tags/v')
with:
files: OriginalMS-*.zip
publish-docker:
name: Publish GitHub Container Package (GHCR)
runs-on: ubuntu-latest
needs: publish-releases
permissions:
contents: read
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v7
# The old version probed for a Dockerfile and set a flag that gated every
# step below it. With no Dockerfile the job skipped everything and
# reported SUCCESS, so a workflow named "Publish GitHub Container
# Package" could publish nothing and still go green. The Dockerfile is
# required here, so its absence is an error rather than a quiet skip.
- name: Require a Dockerfile
run: |
if [ ! -f Dockerfile ]; then
echo "::error::No Dockerfile at the repository root. This job exists to publish a container image."
exit 1
fi
# build-push-action drives buildx. Runner images ship it, but relying on
# a preinstalled tool makes this job depend on image contents rather than
# on anything declared here.
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# The image path is lowercase literal on purpose: GHCR rejects uppercase
# repository names, and github.repository_owner is "BiosSystem".
- name: Sanitize image tag
id: sanitize
run: |
REF_NAME="${{ github.ref_name }}"
echo "safe_tag=${REF_NAME//\//-}" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
push: true
tags: ghcr.io/biossystem/originalms:latest,ghcr.io/biossystem/originalms:${{ steps.sanitize.outputs.safe_tag }}
cache-from: type=gha
cache-to: type=gha,mode=max