-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0b7864
commit 2782dbe
Showing
11 changed files
with
236 additions
and
72 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
name: Automatic Release | ||
# Workflow Name: Automatic Release | ||
|
||
# Description: | ||
# This GitHub Actions workflow is triggered when a tag is pushed. It builds the Cloney application | ||
# for multiple platforms, creates zip archives, generates checksums, and releases the artifacts | ||
# using the release-action GitHub action. | ||
|
||
# Trigger the workflow when a tag is pushed. | ||
on: | ||
# Trigger when a tag is pushed. | ||
push: | ||
tags: | ||
- "*" | ||
|
@@ -15,35 +20,37 @@ jobs: | |
contents: write | ||
|
||
steps: | ||
# Check out the repository. | ||
# Step 1: Check out the repository. | ||
- uses: actions/checkout@v3 | ||
|
||
# Setup Go. | ||
# Step 2: Setup Go. | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.21" | ||
|
||
# Install goversioninfo to embed properties into the Windows executable. | ||
# Step 3: Install goversioninfo to embed properties into the Windows executable. | ||
- name: Install goversioninfo | ||
run: | | ||
go get github.com/josephspurrier/[email protected] | ||
go install github.com/josephspurrier/goversioninfo | ||
# Run go generate. | ||
- name: Run Go Generate | ||
run: go generate | ||
run: go install github.com/josephspurrier/goversioninfo/cmd/[email protected] | ||
|
||
# Build the application for different platforms. | ||
# Step 4: Build the application for different platforms. | ||
- name: Build Application | ||
run: | | ||
goversioninfo -64 | ||
stat resource.syso | ||
GOOS=windows GOARCH=amd64 go build -o cloney-windows-amd64/cloney.exe | ||
rm -f resource.syso | ||
goversioninfo -arm | ||
stat resource.syso | ||
GOOS=windows GOARCH=arm64 go build -o cloney-windows-arm64/cloney.exe | ||
rm -f resource.syso | ||
GOOS=linux GOARCH=amd64 go build -o cloney-linux-amd64/cloney | ||
GOOS=linux GOARCH=arm64 go build -o cloney-linux-arm64/cloney | ||
GOOS=darwin GOARCH=amd64 go build -o cloney-darwin-amd64/cloney | ||
GOOS=darwin GOARCH=arm64 go build -o cloney-darwin-arm64/cloney | ||
# Zip the application for different platforms. | ||
# Step 5: Zip the application for different platforms. | ||
- name: Zip Application | ||
run: | | ||
zip -r cloney-windows-amd64.zip cloney-windows-amd64 | ||
|
@@ -53,7 +60,7 @@ jobs: | |
zip -r cloney-darwin-amd64.zip cloney-darwin-amd64 | ||
zip -r cloney-darwin-arm64.zip cloney-darwin-arm64 | ||
# Generate checksums for the application. | ||
# Step 6: Generate checksums for the application. | ||
- name: Generate Checksums | ||
run: | | ||
sha256sum cloney-windows-amd64.zip > cloney-windows-amd64-checksum.sha256 | ||
|
@@ -63,7 +70,7 @@ jobs: | |
sha256sum cloney-darwin-amd64.zip > cloney-darwin-amd64-checksum.sha256 | ||
sha256sum cloney-darwin-arm64.zip > cloney-darwin-arm64-checksum.sha256 | ||
# Use the release-action GitHub action to create a release. | ||
# Step 7: Use the release-action GitHub action to create a release. | ||
- name: Create Release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
name: Automatic Tag | ||
# Workflow Name: Automatic Tag | ||
|
||
# Description: | ||
# This GitHub Actions workflow automates the tagging process when a pull request is closed on the 'main' branch. | ||
# It determines the next version using the GitHub Tag Action, updates version-related files, and pushes the tag. | ||
|
||
# Trigger the workflow when a pull request is closed on the 'main' branch. | ||
on: | ||
# Trigger the workflow when a pull request is closed on the 'main' branch. | ||
pull_request: | ||
types: | ||
- closed | ||
|
@@ -17,15 +21,67 @@ jobs: | |
contents: write | ||
|
||
steps: | ||
# Check out the repository. | ||
# Step 1: Check out the repository. | ||
- uses: actions/checkout@v3 | ||
with: | ||
# Check out the specific commit associated with the closed pull request. | ||
ref: ${{ github.event.pull_request.merge_commit_sha }} | ||
# Fetch all commit history for tags to work correctly. | ||
fetch-depth: "0" | ||
|
||
# Use the GitHub Tag Action to create tags. | ||
# Step 2: Run auto-tag in dry-run mode to determine the next version of Cloney. | ||
- name: 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 3: Extract version information from the output of the previous step. | ||
- name: 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 4: Edit the versioninfo.json file to update the version. | ||
- name: Edit versioninfo.json File | ||
run: | | ||
sed -i "s/\"Major\": -1/\"Major\": $CLONEY_NEXT_VERSION_MAJOR/" versioninfo.json | ||
sed -i "s/\"Minor\": -1/\"Minor\": $CLONEY_NEXT_VERSION_MINOR/" versioninfo.json | ||
sed -i "s/\"Patch\": -1/\"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 5: Edit the pkg/config/config.go file to update the version. | ||
- name: 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 6: Edit the installation/install.sh file to update the version. | ||
- name: 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 | ||
# Step 7: Use the GitHub Tag Action to create the tag and push it to the repository. | ||
- name: Bump Version and Push Tag. | ||
uses: anothrNick/[email protected] | ||
env: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,123 @@ | ||
name: Run Automated Tests | ||
# 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. | ||
|
||
# Trigger when a PR is created against the main branch and when a commit is pushed to the main branch. | ||
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 | ||
|
||
steps: | ||
# Check out the repository. | ||
- uses: actions/checkout@v3 | ||
# Step 1: Check out the repository. | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
# Set up Go. | ||
- uses: actions/setup-go@v4 | ||
# Step 2: Setup Go. | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.21" | ||
|
||
# Run the tests. | ||
# Step 3: Run the tests. | ||
- name: Run Tests | ||
run: go test ./... -v | ||
|
||
# | ||
# Check if there are no errors when building the application. | ||
# Validate auto-tagging steps. | ||
# | ||
|
||
# Install goversioninfo to embed properties into the Windows executable. | ||
- name: Check Install goversioninfo | ||
# 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: | | ||
go get github.com/josephspurrier/[email protected] | ||
go install github.com/josephspurrier/goversioninfo | ||
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)" | ||
# Run go generate. | ||
- name: Check Run Go Generate | ||
run: go generate | ||
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 | ||
# Build the application. | ||
- name: Build Application | ||
run: GOOS=windows GOARCH=amd64 go build -o cloney-windows-amd64/cloney.exe | ||
# 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 | ||
# Zip the application. | ||
- name: Check Zip Application | ||
# Step 11: Validate creating a zip archive. | ||
- name: Validate Zip Application | ||
run: zip -r cloney-windows-amd64.zip cloney-windows-amd64 | ||
|
||
# Generate checksum for the application. | ||
- name: Check Generate Checksums | ||
# Step 12: Validate generating checksum for the application. | ||
- name: Validate Generate Checksums | ||
run: sha256sum cloney-windows-amd64.zip > cloney-windows-amd64-checksum.sha256 | ||
|
||
# Check if the checksum matches. | ||
- name: Check Checksum Matches | ||
# Step 13: Validate checksum matches. | ||
- name: Validate Checksum Matches | ||
run: sha256sum -c cloney-windows-amd64-checksum.sha256 |
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
Oops, something went wrong.