-
Notifications
You must be signed in to change notification settings - Fork 2
134 lines (109 loc) · 5.77 KB
/
go.yml
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
name: Build
on: [ push, pull_request ]
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners
os: [ 'ubuntu-20.04', 'ubuntu-22.04', 'ubuntu-24.04', 'ubuntu-latest', 'macos-13', 'macos-14', 'macos-15', 'macos-latest', 'windows-2019', 'windows-2022', 'windows-latest' ]
steps:
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
cache: false
go-version-file: 'go.mod'
check-latest: true
- run: go test
- shell: bash
run: cat Makefile | grep "^VERSION=" | sed -e "s/VERSION/fmcsadmin_version/g" >> "$GITHUB_ENV"
- run: go build -ldflags "-X main.version=${{ env.fmcsadmin_version }}" fmcsadmin.go
- if: runner.os == 'macOS'
run: make dist && cp -p "dist/fmcsadmin-${{ env.fmcsadmin_version }}-macos/fmcsadmin" .
- if: runner.os == 'Linux' && matrix.os == 'ubuntu-22.04'
run: make build-linux-arm64
- shell: bash
run: echo "goss_commit_hash=5704120d25902119cb1139e04bca3db7742a9f73" >> "$GITHUB_ENV" # v0.4.9
- if: runner.os == 'macOS' || runner.os == 'Windows'
shell: bash
run: echo "GOSS_USE_ALPHA=1" >> "$GITHUB_ENV"
- if: runner.os == 'Linux' && (github.repository_owner == 'emic' || github.repository_owner == 'matsuo')
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN_202507 }}
- if: runner.os == 'Linux' && (github.repository_owner == 'emic' || github.repository_owner == 'matsuo')
name: Pull from GitHub Container Registry
run: |
docker pull --platform=linux/amd64 ghcr.io/matsuo/goss:latest
docker run --platform=linux/amd64 --rm -i -v /$(pwd):/tmp ghcr.io/matsuo/goss:latest bash <<'EOF'
cd /root/go/src/github.com/goss-org/goss
cp ./release/goss-darwin-amd64 /tmp/goss-darwin-amd64
cp ./release/goss-darwin-arm64 /tmp/goss-darwin-arm64
cp ./release/goss-linux-amd64 /tmp/goss-linux-amd64
cp ./release/goss-linux-arm64 /tmp/goss-linux-arm64
EOF
- if: runner.os == 'macOS' || (runner.os == 'Linux' && !(github.repository_owner == 'emic' || github.repository_owner == 'matsuo'))
run: |
curl -L "https://github.com/goss-org/goss/archive/${{ env.goss_commit_hash }}.tar.gz" -o goss.tar.gz
tar xzvf goss.tar.gz
cd "goss-${{ env.goss_commit_hash }}"
make build
cd ..
- if: runner.os == 'Windows'
shell: bash
run: |
curl -L "https://github.com/goss-org/goss/archive/${{ env.goss_commit_hash }}.tar.gz" -o goss.tar.gz
tar xzvf goss.tar.gz
cd "goss-${{ env.goss_commit_hash }}"
go build -o goss-windows-amd64.exe github.com/goss-org/goss/cmd/goss
mkdir release
mv goss-windows-amd64.exe release/
cd ..
- if: runner.os == 'Linux' && (github.repository_owner == 'emic' || github.repository_owner == 'matsuo')
run: |
./goss-linux-amd64 --version
OS=linux ./goss-linux-amd64 --gossfile tests/goss.yaml validate --format documentation
- if: runner.os == 'Linux' && !(github.repository_owner == 'emic' || github.repository_owner == 'matsuo')
run: |
OS=linux "./goss-${{ env.goss_commit_hash }}/release/goss-linux-amd64" --gossfile tests/goss.yaml validate --format documentation
- if: runner.os == 'macOS'
run: |
OS=darwin "./goss-${{ env.goss_commit_hash }}/release/goss-darwin-amd64" --gossfile tests/goss.yaml validate --format documentation
- if: runner.os == 'Windows'
shell: bash
run: |
OS=windows "./goss-${{ env.goss_commit_hash }}/release/goss-windows-amd64.exe" --gossfile tests/goss.yaml validate --format documentation
- run: ./fmcsadmin -v
- if: runner.os == 'Linux' && matrix.os == 'ubuntu-22.04'
name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
- if: runner.os == 'macOS' && matrix.os == 'macos-14'
run: |
docker run --rm --env GOSS_COMMIT_HASH=${{ env.goss_commit_hash }} -i -v /$(pwd):/tmp arm64v8/ubuntu:22.04 bash <<'EOF'
cd /tmp
cp -p ./dist/linux-arm64/fmcsadmin ./fmcsadmin
OS=linux "./goss-linux-arm64" --gossfile tests/goss.yaml validate --format documentation
./fmcsadmin -v
EOF
- name: Create dmg format file for macOS
if: runner.os == 'macOS'
run: |
lipo -info "dist/fmcsadmin-${{ env.fmcsadmin_version }}-macos/fmcsadmin"
cd "dist/fmcsadmin-${{ env.fmcsadmin_version }}-macos"
pkgbuild --root . --identifier jp.co.emic.fmcsadmin --version "${{ env.fmcsadmin_version }}" --install-location /usr/local/bin ../fmcsadmin.pkg
cd ..
cp -p ../{LICENSE.txt,README.md,NOTICE.txt,release-notes.txt} .
cp -p ../macOS/{Distribution.xml,welcome.txt} .
productbuild --distribution Distribution.xml --resources . --package-path fmcsadmin.pkg "fmcsadmin-${{ env.fmcsadmin_version }}-unsigned.pkg"
cp -p "fmcsadmin-${{ env.fmcsadmin_version }}-unsigned.pkg" "fmcsadmin-${{ env.fmcsadmin_version }}.pkg"
mkdir macos-dist
mv "fmcsadmin-${{ env.fmcsadmin_version }}.pkg" macos-dist/
mv {LICENSE.txt,README.md,NOTICE.txt,release-notes.txt} macos-dist/
cd macos-dist
cd ..
hdiutil create -srcfolder ./macos-dist/ -fs HFS+ -format UDZO -volname "fmcsadmin-${{ env.fmcsadmin_version }}" "fmcsadmin-${{ env.fmcsadmin_version }}-macos.dmg"