Cloney 1.1.0 #18
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Workflow Name: Run Automated Tests | |
# Description: | |
# This GitHub Actions workflow is triggered when a pull request is created against the main branch | |
# or when a commit is pushed to the main branch. It runs automated tests for the Go application, | |
# and validates the build steps (e.g., building the Windows executable, creating a zip archive, | |
# and generating checksums) without actually releasing the application. | |
on: | |
# Trigger when a PR is created against the main branch. | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
branches: | |
- main | |
# Trigger when a commit is pushed to the main branch. | |
push: | |
branches: | |
- main | |
jobs: | |
test: | |
runs-on: ubuntu-22.04 | |
# Give permissions to modify repository contents. | |
permissions: | |
contents: write | |
steps: | |
# Step 1: Check out the repository. | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
# Step 2: Setup Go. | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.21" | |
# Step 3: Run the tests. | |
- name: Run Tests | |
run: go test ./... -v | |
# | |
# Validate auto-tagging steps. | |
# | |
# Step 4: Run auto-tag in dry-run mode to determine the next version of Cloney. | |
- name: Validate Determine Next Version | |
id: determine_next_version | |
uses: anothrNick/[email protected] | |
env: | |
# Do not prepend the 'v' prefix to the tag. | |
WITH_V: false | |
DRY_RUN: true | |
# Step 5: Extract version information from the output of the previous step. | |
- name: Validate Export Version Information | |
run: | | |
CLONEY_NEXT_VERSION_FULL="${{ steps.determine_next_version.outputs.new_tag }}" | |
CLONEY_NEXT_VERSION_MAJOR="$(echo $CLONEY_NEXT_VERSION_FULL | cut -d. -f1)" | |
CLONEY_NEXT_VERSION_MINOR="$(echo $CLONEY_NEXT_VERSION_FULL | cut -d. -f2)" | |
CLONEY_NEXT_VERSION_PATCH="$(echo $CLONEY_NEXT_VERSION_FULL | cut -d. -f3)" | |
echo "CLONEY_NEXT_VERSION_FULL=$CLONEY_NEXT_VERSION_FULL" >> "$GITHUB_ENV" | |
echo "CLONEY_NEXT_VERSION_MAJOR=$CLONEY_NEXT_VERSION_MAJOR" >> "$GITHUB_ENV" | |
echo "CLONEY_NEXT_VERSION_MINOR=$CLONEY_NEXT_VERSION_MINOR" >> "$GITHUB_ENV" | |
echo "CLONEY_NEXT_VERSION_PATCH=$CLONEY_NEXT_VERSION_PATCH" >> "$GITHUB_ENV" | |
# Step 6: Validate Edit the versioninfo.json file to update the version. | |
- name: Validate Edit versioninfo.json File | |
run: | | |
sed -i "s/\"Major\": 0/\"Major\": $CLONEY_NEXT_VERSION_MAJOR/" versioninfo.json | |
sed -i "s/\"Minor\": 0/\"Minor\": $CLONEY_NEXT_VERSION_MINOR/" versioninfo.json | |
sed -i "s/\"Patch\": 0/\"Patch\": $CLONEY_NEXT_VERSION_PATCH/" versioninfo.json | |
sed -i "s/\"ProductVersion\": \"X.X.X\"/\"ProductVersion\": \"$CLONEY_NEXT_VERSION_FULL\"/" versioninfo.json | |
if git diff --exit-code versioninfo.json; then | |
echo "versioninfo.json is unchanged but should have been updated." | |
exit 1 | |
fi | |
# Step 7: Validate Edit the pkg/config/config.go file to update the version. | |
- name: Validate Edit pkg/config/config.go File | |
run: | | |
sed -i "s/AppVersion: \"X.X.X\"/AppVersion: \"$CLONEY_NEXT_VERSION_FULL\"/" pkg/config/config.go | |
if git diff --exit-code pkg/config/config.go; then | |
echo "pkg/config/config.go is unchanged but should have been updated." | |
exit 1 | |
fi | |
# Step 8: Validate Edit the installation/install.sh file to update the version. | |
- name: Validate Edit installation/install.sh File | |
run: | | |
sed -i "s/CLONEY_VERSION=\"X.X.X\"/CLONEY_VERSION=\"$CLONEY_NEXT_VERSION_FULL\"/" installation/install.sh | |
if git diff --exit-code installation/install.sh; then | |
echo "installation/install.sh is unchanged but should have been updated." | |
exit 1 | |
fi | |
# | |
# Validate build steps (not actual release). | |
# | |
# Step 9: Install goversioninfo to embed properties into the Windows executable. | |
- name: Install goversioninfo | |
run: go install github.com/josephspurrier/goversioninfo/cmd/[email protected] | |
# Step 10: Validate building the application for Windows. | |
- name: Validate Build for Windows | |
run: | | |
goversioninfo -64 | |
stat resource.syso | |
GOOS=windows GOARCH=amd64 go build -o cloney-windows-amd64/cloney.exe | |
rm -f resource.syso | |
# Step 11: Validate creating a zip archive. | |
- name: Validate Zip Application | |
run: zip -r cloney-windows-amd64.zip cloney-windows-amd64 | |
# Step 12: Validate generating checksum for the application. | |
- name: Validate Generate Checksums | |
run: sha256sum cloney-windows-amd64.zip > cloney-windows-amd64-checksum.sha256 | |
# Step 13: Validate checksum matches. | |
- name: Validate Checksum Matches | |
run: sha256sum -c cloney-windows-amd64-checksum.sha256 | |
# Commit the changes in a new branch. | |
- name: Commit Version Updates | |
run: | | |
git checkout -b version-bump-${{ github.run_id }} | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git add versioninfo.json pkg/config/config.go installation/install.sh | |
git commit -m "Bump Version to $CLONEY_NEXT_VERSION_FULL." | |
git push origin version-bump-${{ github.run_id }} |